http://blog.csdn.net/wwlearn/article/details/5457310
<authorization>
<deny users = " ? "/>
<allow users= " * " />
</authorization>
?:匿名用户,也就是没有登入的用户不能访问。
*:所有用户,所有用户都不能访问。
<deny users = " ? "/>、 是拒绝匿名用户访问
<allow users= " * " /> 允许所有的用户访问包括匿名用户
<authentication mode= " Forms ">
<forms name= " .ASPXAUTH " loginUrl= " ~/login.aspx "></forms>
<!-- 默认cookie 名 及登陆页面地址 -->
</authentication>
<authorization>
<deny users= " ? "></deny> <!-- 禁止匿名访问 -->
</authorization>
<location path= " Default.aspx "><!--允许所有人访问这个页面-->
<system.web>
<authorization>
<allow users= " * "/>
</authorization>
</system.web>
</location>
// 自定义票据,获取用户的roles,写到票据中。票据会携带在cookie中。
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
1, // version
loginID, // user name
DateTime.Now, // creation
DateTime.Now.AddMinutes( 60 * 20), // Expiration
false, // Persistent
""); // userData
String encryptedTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(authCookie);
<deny users = " ? "/>
<allow users= " * " />
</authorization>
?:匿名用户,也就是没有登入的用户不能访问。
*:所有用户,所有用户都不能访问。
<deny users = " ? "/>、 是拒绝匿名用户访问
<allow users= " * " /> 允许所有的用户访问包括匿名用户
<authentication mode= " Forms ">
<forms name= " .ASPXAUTH " loginUrl= " ~/login.aspx "></forms>
<!-- 默认cookie 名 及登陆页面地址 -->
</authentication>
<authorization>
<deny users= " ? "></deny> <!-- 禁止匿名访问 -->
</authorization>
<location path= " Default.aspx "><!--允许所有人访问这个页面-->
<system.web>
<authorization>
<allow users= " * "/>
</authorization>
</system.web>
</location>
// 自定义票据,获取用户的roles,写到票据中。票据会携带在cookie中。
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
1, // version
loginID, // user name
DateTime.Now, // creation
DateTime.Now.AddMinutes( 60 * 20), // Expiration
false, // Persistent
""); // userData
String encryptedTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(authCookie);