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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *