在 Web.Config 的位置路径元素中指定多个目录 [英] Specify more than one directory in Web.Config's Location Path element

查看:36
本文介绍了在 Web.Config 的位置路径元素中指定多个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 ASP.NET 的 Web 配置文件中,我定义了以下位置元素:

In my ASP.NET's Web Config file I have the following location elements defined:

  <location path="">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>

  <location path="dir1">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>

  <location path="dir2">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>

上面的例子指定了除了两个目录 dir1 和 dir2 之外的所有目录都将被锁定给匿名用户.

The example above is specifying that all directories will be locked down to anonymous users except the two directories dir1 and dir2.

我很好奇是否有一种语法可以让我在一个位置元素中定义多个目录.例如,如果我们能做这样的事情就很方便了...

I'm curious if there is a syntax that I can use that will allow me to define more than one directory within one location element. For example, it would be convenient if we could do something like this...

  <location path="dir1,dir2,etc">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>

推荐答案

抱歉,路径属性不允许使用,"所以你必须为所有路径写标签,或者您可以在每个目录中创建 web.config.

sorry, but path property doesn't allow to use "," so you must write tag for all path, Or you can create web.config in each directory.

这篇关于在 Web.Config 的位置路径元素中指定多个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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