在Web.config页面中填写代码如下图:
在credentials配置节中添加两个登录用户,且不使用加密方式
<authentication mode="Forms">
<forms defaultUrl="MemberList.aspx" loginUrl="Login.aspx">
<credentials passwordFormat="Clear">
<user name="admin" password="123"/>
<user name="guest" password="456"/>
</credentials>
</forms>
</authentication>
defaulturl=要跳转的页面,loginurl=登录页面
然后在location 配置拒绝匿名用户和guest用户访问,允许admin用户
<location path="Admin/MemberList.aspx"> //path=要跳转的页面
<system.web>
<authorization>
<deny users="guest,?"/>
<allow users="admin"/>
</authorization>
</system.web>
</location>