Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to security different folder in asp.net
Posted
Comments
DamithSL 23-Nov-14 12:24pm    
what kind of security you need? can you elaborate?
Zoltán Zörgő 23-Nov-14 14:13pm    
ASP.NET... Web Forms? MVC? Web pages?
iamvinod34 23-Nov-14 21:53pm    
Web forms and asp.net folders and web.config
Sergey Alexandrovich Kryukov 23-Nov-14 22:14pm    
Why? If you don't give access to some of your directories, they won't be accessible. At the same time, you can access them internally in your code behind. Isn't that simple? If you have some particular scenario you cannot implement, just tell us about it.
—SA
iamvinod34 18-Dec-14 6:24am    
My site name is:http:www.onlineexamsworld.com
after login into my web site i am getting folder names instead of URL .it for security purpose
help me plz

1 solution

ASP.NET defines different folders for you to add your data in, your code, user data, references can all be saved in those folders, and ASP.NET will automatically just deny any request to those folders and any thing in them will be safe and un-accessible. Using these folders is a better move rather than creating your own logic to control the URLs where the user can navigate to and where not to.

You will get the list here, http://msdn.microsoft.com/en-us/library/ex526337.aspx[^]. Mostly used folders are App_Data, App_Code.


  • App_Code: Used to store all your server-side code, such as C# class files etc.
  • App_Data: Can contain the databases and other data that needs to be made secure.


There are folders meant for each and every purpose whose list can be easily read at the MSDN post link I have given. Read them and use them as required. ASP.NET will take care of the security and all other stuff required and the user will always see a 404 when surfing to the location where they're present.

Secondly, from your web.config folder you can add the error to the location of your folder, so that when user makes a request to that folder he gets a 404.
 
Share this answer
 
v2
Comments
Manas Bhardwaj 23-Nov-14 12:50pm    
Yes +5!
Afzaal Ahmad Zeeshan 23-Nov-14 13:23pm    
Thanks Manas, :)
iamvinod34 18-Dec-14 6:24am    
My site name is:http:www.onlineexamsworld.com
after login into my web site i am getting folder names instead of URL .it for security purpose
help me plz
Afzaal Ahmad Zeeshan 18-Dec-14 9:46am    
Did you try to follow the answer?

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