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

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

问题描述

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

 <位置路径=>
    <&的System.Web GT;
      <授权>
        <拒绝用户= /&gt的帮助?
      < /授权>
    < /system.web>
  < /地点>  <位置路径=DIR1>
    <&的System.Web GT;
      <授权>
        <让用户= /&gt的帮助?
      < /授权>
    < /system.web>
  < /地点>  <位置路径=DIR2>
    <&的System.Web GT;
      <授权>
        <让用户= /&gt的帮助?
      < /授权>
    < /system.web>
  < /地点>

上面的例子是规定所有目录将被锁定匿名用户除了两个目录DIR1 DIR2和

我很好奇,如果有一个语法,我可以使用,这将让我一个位置元素中定义多个目录。例如,这将是方便,如果我们可以做这样的事情...

 <位置路径=DIR1,DIR2等>
    <&的System.Web GT;
      <授权>
        <让用户= /&gt的帮助?
      < /授权>
    < /system.web>
  < /地点>


解决方案

抱歉,但path属性不允许使用,
所以你必须写标签的所有路径,
或者你可以在每个目录下创建的web.config。

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>

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>

解决方案

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天全站免登陆