web.config十大原则一(翻译)

很喜欢这篇外文,于是决定翻译一下,做个收藏,同时也共享给各位。这篇文章很长,所以就一个个来了。

原文链接

http://weblogs.asp.net/jgalloway/archive/2012/01/17/10-things-asp-net-developers-should-know-about-web-config-inheritance-and-overrides.aspx
 

Tip 1: Using Web.config files in site subfolders

译:在子目录里用你的web.config

And ASP.NET website's Web.config is part of an inheritance chain. Your website's subfolders can have Web.config - an example is the Web.config file in an ASP.NET MVC application's View folder which does things like preventing directly viewing the View templates:

译:

asp.net 网站的web.config是继承链的一部分,所以你的网站的子目录的也能有一个自己的web.config(当然它会继承个目录的web.config的信息),一个例子

是你可以在asp.net的mvc程序的视图文件夹的web.config指定一个视图模板路径

2012-01-12 23h57_09

This allows for setting general settings at the site level and overriding them when necessary. Any settings in the base Web.config that aren't overridden in the subfolder stay in effect, so the "child" Web.config can be pretty small. You can continue to nest them, so sub-sub-subfolders can get their own Web.config if needed. Some of the most common uses of subfolders are to restrict permission (e.g. requiring authentication or restricting access to resources), but you can also use them to do things like include default namespaces in Views, toggle handlers, etc.

 译:这意味着你可以在网站根目录的web.config放置一些常用的东西并且会覆盖子文件夹中的web.config的相同的设置,而且子文件夹的设置则不会覆盖根目录的web.config.所以这个子的web.cofig是可以非常小的。你能继续嵌套它们,所以每个子文件夹都能获得自己的web.config.你能用它们进行不同目录的权限设置,也能用它们指定针对某个文件夹的特殊设置,像视图,handler等等。

原文地址:https://www.cnblogs.com/chenleinet/p/2367173.html