简体   繁体   English

使用根web.config而不是子文件夹web.config

[英]use root web.config instead of sub-folders web.config


i was trying to find out how can i use only root web.config instead of each one in any sub-folders of a ASP.NET Webforms project on the internet, but unfortunately i could not find propper answer. 我试图找出如何只使用根web.config而不是Internet上ASP.NET Webforms项目的任何子文件夹中的每个子文件夹,但是很遗憾,我找不到合适的答案。 for example we have a project that has sub-folders like Administrator or Users and in the each one we have Web.Config files that authenticate users and restrict users by their permission. 例如,我们有一个项目,其中包含子文件夹,如AdministratorUsers ,在每个项目中,我们都有Web.Config文件,这些文件对用户进行身份验证并通过其权限限制用户。
With this mentioned issue, is it possible that we use ONLY a root web.config to authenticate users without any web.config in sub-folders? 有了这个提到的问题,是否有可能我们使用根web.config来对用户进行身份验证,而子文件夹中没有任何web.config?


Please help me. 请帮我。

Shadman 沙德曼

You can use location element 您可以使用location元素
example

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

You cannot combine <location> and <authorization> tags in a web.config file . 您不能在web.config文件中组合<location><authorization>标记 You need to have config files for your sub-directories as well, or there is a workaround for a single config file that adds code to your aspx and code-behind files. 您还需要具有子目录的配置文件,或者有一个针对单个配置文件的变通方法,该配置文件将代码添加到aspx和代码隐藏文件中。

Web.config allow location access for specific user Web.config允许特定用户访问位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM