Home > Software engineering >  How can I use MapFallbackToFile in Asp.Net Core?
How can I use MapFallbackToFile in Asp.Net Core?

Time:12-16

I can install a fallback route with a string

app.MapFallback(() => "some text");

but if I replace this with

app.MapFallbackToFile("text.txt"); // works neither relative 
app.MapFallbackToFile("c:\\folder\\text.txt"); // nor with full path

I receive HTTP 404. How does MapFallbackToFile work?

CodePudding user response:

Try to place text.txt file inside wwwroot folder and also add the UseStaticFiles middleware.

app.UseStaticFiles();

...

app.MapFallbackToFile("text.txt");
  • Related