如何在asp.net c#中保护文件夹? [英] how to secure folder in asp.net c#?

查看:81
本文介绍了如何在asp.net c#中保护文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中安装不同的文件夹

解决方案

ASP.NET定义了不同的文件夹,供您添加数据,代码,用户数据,引用可以全部保存在这些文件夹中,ASP.NET将自动拒绝对这些文件夹的任何请求,其中的任何内容都将是安全且无法访问的。使用这些文件夹是一个更好的举措,而不是创建自己的逻辑来控制用户可以导航到的URL和不用的URL。



您将在此处获取列表, http ://msdn.microsoft.com/en-us/library/ex526337.aspx [ ^ ]。最常用的文件夹是App_Data,App_Code。





  • App_Code:用于存储所有服务器端代码,例如C#类文件等。
  • App_Data:可以包含需要安全的数据库和其他数据。




有文件夹意味着对于每个目的,其列表可以在我给出的MSDN帖子链接中轻松阅读。阅读它们并根据需要使用它们。 ASP.NET将负责安全性和所需的所有其他内容,用户在浏览到他们所在的位置时将始终看到404。



其次,从您的web.config文件夹中,您可以将错误添加到文件夹的位置,这样当用户向该文件夹发出请求时,他会获得404

how to security different folder in asp.net

解决方案

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.


这篇关于如何在asp.net c#中保护文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆