.NET: understanding web.config in asp.net

北城以北 提交于 2019-12-14 04:17:07

问题


Does anyone know of a good link to explain how to use the web.config......

For example, i am using forms authentication... and i notice there is a system.web and then it closed /system.web and then below configuration there are additional location tags

here is an example, if you ntoice there is an authentication mode=forms with authorization i presume this is the ROOT....... It is also self contained within a system.web .... Below this there are more location= with system.web tags....

I have never really understand what i am actually doing.. I have tried checkign the MSDN documentation but still i don't fully understand up....

Can anyone help?

If you notice with my example.... everything is stored in 1 web.config... i thought the standard waas create a standard web.config and then create another web.config in the directory where i wish to protect it..???

<configuration>

     <system.web>
           <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />

           <authentication mode="Forms">
        <forms loginUrl="Login.aspx" defaultUrl="Login.aspx" cookieless="UseCookies" timeout="60"/>
    </authentication>

    <authorization>
        <allow users="*"/>
    </authorization>

       </system.web>


<location path="Forms">
    <system.web>
        <authorization>
            <deny users="?"/>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>
<location path="Forms/Seguridad">
    <system.web>
        <authorization>
            <allow roles="Administrador"/>
            <deny users="?"/>
        </authorization>
    </system.web>
</location>

回答1:


Standard entries (web.config is extensible) are well documented therein.

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

is a good start.

It is - as should be obvious - XML based, btw.




回答2:


You can place following web.config file in Forms/Seguridad:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <authorization>
            <allow roles="Administrators" />
            <deny users="*" />
        </authorization>
    </system.web>
</configuration>


来源:https://stackoverflow.com/questions/2622302/net-understanding-web-config-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!