Skip to content

Instantly share code, notes, and snippets.

@sirojiddin0198
Created August 27, 2025 02:25
Show Gist options
  • Select an option

  • Save sirojiddin0198/74fef9ecb80b6aca0b22b94bde9b2c23 to your computer and use it in GitHub Desktop.

Select an option

Save sirojiddin0198/74fef9ecb80b6aca0b22b94bde9b2c23 to your computer and use it in GitHub Desktop.
Questions

Middleware Savollari

Q1. ASP.NET Core’da middleware nima qiladi?
A) Faqatgina HTTP response yaratadi
B) HTTP so‘rovlarini ketma-ket qayta ishlaydi
C) Faqat routing uchun ishlatiladi
D) Faqat xatolarni log qiladi

✔️ To‘g‘ri javob: B


Q2. Quyidagi qaysi method keyingi middleware’ni chaqiradi?
A) await next()
B) return;
C) app.Run()
D) context.Response.WriteAsync()

✔️ To‘g‘ri javob: A


Q3. Middleware’lar chaqirilish tartibi kodda yozilgan tartibga bog‘liq.
✔️ True


Q4. app.Run() dan keyin yozilgan barcha middleware’lar ham ishlaydi.
✔️ False


Q5. ASP.NET Core’da middleware pipeline __________ tartibda ishlaydi.
✔️ Javob: ketma-ket (sequential)


Q6. Har bir middleware odatda ikkita vazifani bajaradi: so‘rovni qayta ishlash va __________.
✔️ Javob: keyingi middleware’ni chaqirish


Q7. Quyidagi kodda xatoni toping:

app.Use(async context =>
{
    await context.Response.WriteAsync("Hello Middleware");
    await next(); // ❌
});Xato: next parametr sifatida olinmagan.
  
✅ To‘g‘ri variant:

app.Use(async (context, next) =>
{
    await context.Response.WriteAsync("Hello Middleware");
    await next();
});

Q8. Kodni tahlil qiling:

app.Use(async (context, next) =>
{
    await next();
    await context.Response.WriteAsync("First");
});

app.Use(async (context, next) =>
{
    await context.Response.WriteAsync("Second");
});Xato: Ikkinchi middleware await next(); chaqirmaydi, shu sabab First hech qachon yozilmaydi.

Q9. Quyidagi kodni bajarsak, / ga so‘rov yuborilganda output nima bo‘ladi?

app.Use(async (context, next) => { await context.Response.WriteAsync("A"); await next(); await context.Response.WriteAsync("C"); });

app.Run(async context => { await context.Response.WriteAsync("B"); });

✔️ Javob: ABC


Q10. Quyidagi kodda natija qanday bo‘ladi?

app.Use(async (context, next) => { await context.Response.WriteAsync("X"); });

app.Run(async context => { await context.Response.WriteAsync("Y"); });

✔️ Javob: X (chunki next() chaqirilmagan, Y bajarilmaydi)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment