In a scenario where you have both UseStaticFiles() and UseDefaultFiles() in your Startup.cs, which one should be called first to ensure the default document is correctly served?
- UseStaticFiles()
- UseDefaultFiles()
- It doesn't matter, the order is irrelevant
- UseFileServer()
UseDefaultFiles() should be called before UseStaticFiles() to ensure that default documents (e.g., index.html) are correctly served. UseDefaultFiles() configures the middleware to look for and serve the default documents, and UseStaticFiles() serves static files like CSS, JavaScript, and images. The order is important because UseStaticFiles() might intercept the request before UseDefaultFiles() has a chance to locate and serve the default document.
Loading...
Related Quiz
- Which attribute would be used to enforce that a specific route parameter should be of type integer?
- The primary method used in a Razor Layout to render content from a child view is _______.
- While setting up an ASP.NET Core development environment on macOS, what would be the preferred installation method for the .NET SDK?
- Which method is used to add MVC route handlers and specify the use of default routes?
- Which of the following is NOT a default template option when creating a new ASP.NET Core project?