how to restrict access to files such as gif, jpeg, .js and css files to unauthorized users in an ASP.NET web application? The site is configured with Anonymous access on IIS 8. The content should be hidden/blocked until the user logs in succesfully.
Asked
Active
Viewed 1,175 times
1 Answers
0
You can use forms authentication for that.Copy all your static files in folder Where you can protect your folder and allow only for authenticated users just like below.
<location path="Relative path for folder">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
Here CSS is path of folder Here is a complete example.
http://www.codefixer.com/asp-net/tutorials/protecting-folders-with-forms-authentication.asp

Jalpesh Vadgama
- 13,653
- 19
- 72
- 94
-
IIS will ignore this for static files as it handles them itself and not through ASP.Net. So even if this work on a local copy of the application (where IIS Express hands all requests to ASP.Net) it will not work on a remote server. – jahu Dec 04 '14 at 12:16