I need to prevent access to static files in a folder in an Asp.Net MVC
web application.
I used to prevent access to the following config in the web.config
<location path="help">
<system.web>
<authorization>
<deny users="?" />
<allow users="*"/>
</authorization>
</system.web>
</location>
but this web application is using OWIN and the cookie base middleware and it seems the IIS security check is bypassed
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Login/index"),
CookieHttpOnly = true,
CookieSecure = CookieSecureOption.Always, // https for dev also
});
I thought the iis
security will apply for static files, but even if there's no cookie I can still access the folder.
How can I restrict the access to a specific folder for the authenticated user only?
Regards
Edit: thanks to Tommy comment I can solve my problem but is there any good reading for a better understanding of what we can / can't do using owin and asp.net mvc? I would like to understand why I can't prevent access with deny user ?