我想保护管理页面而不是我网站的所有页面。 [英] I want to protect just the admin page not all pages of my site.
本文介绍了我想保护管理页面而不是我网站的所有页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想保护我网站的管理页面,但我的代码会保护所有页面。
我应该对代码进行哪些更改?
我的尝试:
I want to protect just the Admin page of my site but my code protects all pages.
What changes should I make to my code?
What I have tried:
system.web>
<authentication mode="Forms">
<forms name="SavingsPlan" defaultUrl="admin.aspx" loginUrl="Login.aspx" >
<credentials passwordFormat="SHA1">
<user name="Admin"
password="07B7F3EE06F278DB966BE960E7CBBD103DF30CA6"/>
<user name="User"
password="BA56E5E0366D003E98EA1C7F04ABF8FCB3753889"/>
</credentials>
</forms>
</authentication>
<authorization>
<allow users="Admin"/>
<deny users="?"/>
</authorization>
推荐答案
要指定仅适用于特定文件的配置,请使用< location>
元素:
位置元素(ASP.NET设置架构) [ ^ ]
To specify configuration which only applies to a specific file, use the<location>
element:
location Element (ASP.NET Settings Schema)[^]
<system.web>
<authentication mode="Forms">
...
</authentication>
</system.web>
<location path="admin.aspx">
<system.web>
<authorization>
<allow users="Admin"/>
<deny users="?"/>
</authorization>
</system.web>
</location>
这篇关于我想保护管理页面而不是我网站的所有页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文