How do I serve static files only to authorized users?

前端 未结 5 872
梦毁少年i
梦毁少年i 2020-12-02 22:51

I have a collection of Excel spreadsheets that I\'d like to serve in my ASP.NET 5 webapp only to authorized users.

  1. Where should I store the files? I assume in
5条回答
  •  青春惊慌失措
    2020-12-02 23:29

    Yes, they should go in wwwroot. Currently there is no built-in way to secure wwwroot directories. But creating a middleware module to accomplish it is pretty straightforward. There is an easy to follow tutorial here.

    If you're not familiar with developing middleware, I posted a GitHub project that shows how to create middleware in three easy steps. You can download the project here.

    You don't need a controller to access static files.

提交回复
热议问题