Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to prevent users access for my "~/Content/..." folder i wrote it as follow in "Global.asax.cs"
C#
routes.IgnoreRoute("Content/{*pathInfo}");

but it does not work. am i missing something?
Posted

1 solution

How do you mean does not work? As in, it's being greedy and taking other requests, or as in requests to content/whatever are not being picked up?

Two things to try. First, read an overview[^] on custom routes to make sure what you're doing aligns with what routing is expecting of you.

Secondly, use Nuget (the package manager console in VS) and get glimpse[^] installed on your project. This will help you to debug your routes.

Cheers.
 
Share this answer
 
Comments
reza assar 23-Aug-11 11:47am    
in fact i want to ignore user access from site.css file and other images in Content folder. i put above Routes.Ignore() method at the top of other Routes but when a user write URL: "/Content/site.css" in the browser ,it will route to the css file and don`t prevent user from seeing my css file.
TheyCallMeMrJames 23-Aug-11 12:22pm    
You don't want to do this. The user accessing the URL is absolutely no different from the browser accessing the URL. If you block access to the URL for the CSS, no one will see your CSS. If you want to make it hard to view try minifying your CSS, or use one of the progressing CSS compilers. Cheers.
reza assar 24-Aug-11 3:25am    
thank you for your answer! i got it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900