简体   繁体   中英

Create/Access Custom Configuration Section from location tag of web.config

I want to add some setting for various location and also want to access that per page basis

<location path="Account" myAttr="true">
  <system.web>
     <authorization>
        <allow users="*" />
     </authorization>
  </system.web>
</location>

Or I want to use

<location path="Account">
  <myNode>true</myNode>
  <system.web>
     <authorization>
        <allow users="*" />
     </authorization>
  </system.web>
</location>

Now I want to access this setting in code. I am using MVC3 with ASP.net 4.0 . I found an MSDN article on Custom Sections .

http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

I am not able to use that in location tags.

You can try to add ~ to the path : <location path="~/Account/LogIn">

and I didn't use any true ... (and it works well).

Maybe you should add suitable class and attributes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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