[{"id":"aspnetcorebeginner-001","courseId":"aspnet-core-beginner","domain":"hosting-and-middleware","topic":"Program.cs minimal hosting model","prompt":"In a new ASP.NET Core app that targets .NET 6 or later, a Startup class with ConfigureServices and Configure is the recommended place for app setup.","hint":"Consider how the minimal hosting model compares with the older Startup class.","explain":"ASP.NET Core offers two hosting styles: a Startup class with ConfigureServices and Configure, or setup written directly in Program.cs. Check the startup docs for your framework version.","source":"https://learn.microsoft.com/en-us/aspnet/core/fundamentals/startup","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"The docs say a Startup class is supported on .NET 6 or later, but that using it isn't recommended."},{"id":"b","text":"False","why":"A Startup class is supported on .NET 6 or later, yet the docs advise against using it for new setup."}],"answer":"b","explanation":"On .NET 6 or later, a Startup class is supported but not recommended; the minimal hosting model configures the app from Program.cs.","concept":"On .NET 6 or later, a Startup class is supported but not recommended; the minimal hosting model configures the app from Program.cs.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["A Startup class still works on .NET 6+, but it isn't the recommended style."]},{"id":"aspnetcorebeginner-002","courseId":"aspnet-core-beginner","domain":"hosting-and-middleware","topic":"Middleware order in the pipeline","prompt":"The recommended Program.cs for a non-Development app adds these middleware calls. Put them in the order the app adds them to its pipeline, first to last.","hint":"Think about which call should come first so it can catch errors from the rest.","explain":"Middleware runs in the order it was added, and that order matters for security, performance and features. Each of these calls has a natural place among the others.","source":"https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/index","interaction":{"type":"sort","items":[{"text":"UseExceptionHandler(\"/Error\")","why":"Exception-handling delegates should be called early so they can catch exceptions thrown by later middleware."},{"text":"UseHsts()","why":"The template adds HSTS in the same non-Development block, right after the error handler."},{"text":"UseHttpsRedirection()","why":"Redirects HTTP requests to HTTPS, and sits before static files and routing in the template."},{"text":"UseStaticFiles()","why":"Static assets are served early so the app can short-circuit those requests before routing."},{"text":"UseRouting()","why":"The template calls routing after static files, so requests for those files never reach it."}]},"options":[],"answer":"o:abcde","explanation":"The order of calls in Program.cs is the invocation order: error handling, HSTS, HTTPS redirection, static files, then routing.","concept":"The order of calls in Program.cs is the invocation order: error handling, HSTS, HTTPS redirection, static files, then routing.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Middleware runs in the order you add it in Program.cs, so placement is a design choice."]},{"id":"aspnetcorebeginner-003","courseId":"aspnet-core-beginner","domain":"hosting-and-middleware","topic":"Run as terminal middleware","prompt":"A teammate adds a Use middleware after a Run call in Program.cs. A request arrives. What happens to the Use middleware?","hint":"Think about what a terminal middleware does with the request.","explain":"Each middleware either passes the request to the next one or stops the pipeline. A terminal middleware stops it, so the order of calls decides which middleware the request reaches.","source":"https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/index#use-run-and-map","interaction":{"type":"single"},"options":[{"id":"a","text":"It never runs, because Run is terminal and doesn't pass the request on.","why":"Run adds a terminal delegate, and middleware added after it is never executed."},{"id":"b","text":"It runs first, before the Run delegate, because Use calls are added to the top.","whyNot":"Middleware runs in the order it's added, so a Use call after Run isn't moved ahead of it."},{"id":"c","text":"It runs after Run finishes, as a cleanup step on the response.","whyNot":"The page says a Use call placed after Run is never executed, so it doesn't run afterward either."},{"id":"d","text":"It stops the app at startup, because nothing may follow Run.","whyNot":"The app builds and runs normally; the later call is simply never reached for requests."}],"answer":"a","explanation":"Run adds a terminal request delegate; middleware added after it never executes, because the pipeline stops there.","concept":"Run adds a terminal request delegate; middleware added after it never executes, because the pipeline stops there.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"app.Run(async context =>\n{\n  await context.Response.WriteAsync(\"Hi\");\n});\n\napp.Use(async (context, next) =>\n{\n  await next.Invoke(context);\n});","takeaways":["Middleware added after a terminal Run call never executes."]},{"id":"aspnetcorebeginner-004","courseId":"aspnet-core-beginner","domain":"hosting-and-middleware","topic":"Environment names and default","prompt":"A server runs your app with neither DOTNET_ENVIRONMENT nor ASPNETCORE_ENVIRONMENT set. Which environment does the app run in?","hint":"Look for the fallback the framework uses when no environment variable is found.","explain":"ASP.NET Core reads the environment from two variables, and the environment decides which behaviors run. Developers usually work in Development, and deployed apps use another environment.","source":"https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments","interaction":{"type":"single"},"options":[{"id":"a","text":"Production","why":"With neither variable set, the framework's default environment is Production."},{"id":"b","text":"Development","whyNot":"Development is not the fallback; it applies only when a variable selects it, typically on a developer's machine."},{"id":"c","text":"Staging","whyNot":"Staging is a framework-provided name, but it's used only when a variable selects it."},{"id":"d","text":"No environment; the app refuses to start","whyNot":"The app starts normally, and the default environment applies."}],"answer":"a","explanation":"If DOTNET_ENVIRONMENT and ASPNETCORE_ENVIRONMENT are both unset, the app's environment defaults to Production.","concept":"If DOTNET_ENVIRONMENT and ASPNETCORE_ENVIRONMENT are both unset, the app's environment defaults to Production.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["An unset environment defaults to Production, so set it on developer machines."]},{"id":"aspnetcorebeginner-005","courseId":"aspnet-core-beginner","domain":"hosting-and-middleware","topic":"Static files from wwwroot","prompt":"A team uses MapStaticAssets for its CSS and JavaScript. Which TWO statements about how static files are served are correct?","hint":"Think about when the set of servable files is decided.","explain":"Static files can come from a list generated during build or be read from the web root while the app runs. The call you use decides which of these applies.","source":"https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"MapStaticAssets serves only the assets listed in the build-generated static assets manifest.","why":"The manifest is generated at build and publish time, and MapStaticAssets serves what it lists."},{"id":"b","text":"UseStaticFiles serves files directly from the web root at runtime, including files not in the manifest.","why":"It serves files from the web root while the app runs, which is how files outside the manifest are reached."},{"id":"c","text":"MapStaticAssets scans wwwroot on every request, so new files appear without a rebuild.","whyNot":"The page says MapStaticAssets doesn't scan the web root at runtime; it reads the manifest."},{"id":"d","text":"MapStaticAssets serves any file on disk whose path is correct, even outside the web root.","whyNot":"Files outside the build-time web root aren't in the manifest, so MapStaticAssets doesn't serve them."},{"id":"e","text":"The manifest is created the first time the app receives a request.","whyNot":"The manifest is generated at build and publish time, not on the first request."},{"id":"f","text":"A default document like index.html works with MapStaticAssets alone.","whyNot":"Default documents need UseStaticFiles; MapStaticAssets alone doesn't serve them."}],"answer":"ab","explanation":"MapStaticAssets serves assets from a build-time manifest, while UseStaticFiles serves files from the web root at runtime.","concept":"MapStaticAssets serves assets from a build-time manifest, while UseStaticFiles serves files from the web root at runtime.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["MapStaticAssets serves only manifest files; other files need UseStaticFiles."]}]