asp.net core - How to serve static file with no extension

后端 未结 3 1984
执念已碎
执念已碎 2020-12-06 10:05

ASP.NET Core hapily serves up files from the wwwroot folder based on the mime type of the file. But how do I get it serve up a file with no extension?

A

3条回答
  •  难免孤独
    2020-12-06 10:34

    Adding an alternative solution. You have to set ServeUnknownFileTypes to true and after that set the default content type.

            app.UseStaticFiles(new StaticFileOptions
            {
                ServeUnknownFileTypes = true,
                DefaultContentType = "text/plain"
            });
    

提交回复
热议问题