I have a collection of Excel spreadsheets that I'd like to serve in my ASP.NET 5 webapp only to authorized users.
Thanks much!
We can protect static files with authorization on the ASP.NET Core web application by using the OnPrepareResponse property of the options argument for "Static Files" middleware. Don't forget that place the calling UseAuthentication() at before of the calling UseStaticFiles(...) .
To serve static files for Go 1.12+ in the standard environment, you define the handlers in your app. yaml file using either the static_dir or static_files elements. The content in the static files or static directories are unaffected by the scaling settings in your app.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With