Web.config文件:通配符在位置和授权 [英] Web.config: Wildcards in location and authorization

查看:375
本文介绍了Web.config文件:通配符在位置和授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.Net应用程序我使用的URL路由。结果
URL格式有点像:的http://网站/ {}文化/项目/ {ID}

In my ASP.Net application I'm using URL routing.
The url format is somewhat like: http://site/{culture}/project/{id}.

要允许用户访问登录和恢复页面,我已经添加了以下条目我的web.config:

To allow users to visit the login and recovery page, I've added the following entries to my web.config:

<location path="en-GB/login">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>

<location path="nl-NL/login">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>

<location path="login">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>

有记号的形式,这样我可以跳过EN-GB一部分,并与一个通配符代替它呢?结果
我想登录和恢复页面等可用无论文化。

Is there a form of notation so that I can skip the en-GB part and replace it with a wildcard?
I want the login and recovery page etc. to be available regardless of the culture.

推荐答案

我不相信你可以放置在根web.config相对路径,但是这不是一个问题。您可以使用嵌套的web.config文件中支持你的优势。

I don't believe you can place relative paths in the root web.config, but that isn't a concern. You can use the support of nested Web.Config files to your advantage.

您可以将您的任何子目录的一个类似的web.config文件(调整以适应特定目录的需要),你会得到你所寻求的支持。这也是很多更容易维护的设置更接近他们所控制的code文件。

You can place a web.config file similar to this in any of your sub directories (adjusting to suit the needs of that specific directory) and you'll get the support you seek. It is also a lot easier to maintain as the settings are closer to the code files they control.

<?xml version="1.0"?>
<configuration>
    <system.web>
      <authorization>
        <deny users="*"/>
      </authorization>
    </system.web>
</configuration>

有关身份验证类型,角色等等,整体配置将在web.config在应用程序根目录下完成。其结果是,你不能从这个方法设置每个目​​录单独的登录页面,但你可以有一个登录页面,在需要的时候自动处理重定向(通过分析RETURNURL查询字符串值)。

The overall configuration for authentication types, roles, etc. would be done in the web.config in your applications root directory. As a result, you can't set a separate login page per directory from this method, but you could have a login page that automatically handled a redirect when needed (by analyzing the ReturnURL QueryString value).

这篇关于Web.config文件:通配符在位置和授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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