Private Function CreateAuthTicket(ByVal userName As String, ByVal roles As String, _ ByVal persistent As Boolean) As FormsAuthenticationTicket Return New FormsAuthenticationTicket(1, userName, DateTime.Now, _ DateTime.Now.AddMinutes(60), persistent, roles) End Function Private Function CreateAuthCookie(ByVal authTicket As FormsAuthenticationTicket) As HttpCookie Return New HttpCookie(FormsAuthentication.FormsCookieName, _ FormsAuthentication.Encrypt(authTicket)) End Function写在你验证的地方 Dim authTicket As FormsAuthenticationTicket Dim authCookie As HttpCookie IF 有这个用户意见THENauthTicket = CreateAuthTicket(txtUserID.Text, CStr(viewstate("roles")), False) authCookie = CreateAuthCookie(authTicket) HttpContext.Current.Response.Cookies.Add(authCookie) END IF在web.config 里面增加了下面的代码. 而且也在数据库里面建立了用户表. 但是无论我用什么用户名去登陆, 都不能登陆, 请问我应该用什么用户名去登陆呢? <authentication mode="Forms"> <forms name=".ASPXFORMSDEMO" loginUrl="login.aspx" protection="All" path="/" timeout="1" /> </authentication> <authorization> <allow users="*" /> <!-- 允许所有用户 --> <!-- <allow users="[逗号分隔的用户列表]" roles="[逗号分隔的角色列表]"/> <deny users="[逗号分隔的用户列表]" roles="[逗号分隔的角色列表]"/> --> </authorization>
<forms name="eOfficeLogin" loginUrl="/webs/Login.aspx"/>
</authentication> <authorization>
<deny users="?"/> </authorization>
<authentication mode="Forms">
<forms name="Admin" loginUrl="Login.aspx" path="/" protection="All" timeout="30"/>
</authentication>
<authorization>
<allow users="?" />
</authorization>
ByVal persistent As Boolean) As FormsAuthenticationTicket
Return New FormsAuthenticationTicket(1, userName, DateTime.Now, _
DateTime.Now.AddMinutes(60), persistent, roles)
End Function
Private Function CreateAuthCookie(ByVal authTicket As FormsAuthenticationTicket) As HttpCookie
Return New HttpCookie(FormsAuthentication.FormsCookieName, _
FormsAuthentication.Encrypt(authTicket))
End Function写在你验证的地方
Dim authTicket As FormsAuthenticationTicket
Dim authCookie As HttpCookie IF 有这个用户意见THENauthTicket = CreateAuthTicket(txtUserID.Text, CStr(viewstate("roles")), False)
authCookie = CreateAuthCookie(authTicket)
HttpContext.Current.Response.Cookies.Add(authCookie)
END IF在web.config 里面增加了下面的代码. 而且也在数据库里面建立了用户表. 但是无论我用什么用户名去登陆, 都不能登陆, 请问我应该用什么用户名去登陆呢? <authentication mode="Forms">
<forms name=".ASPXFORMSDEMO" loginUrl="login.aspx"
protection="All" path="/" timeout="1" />
</authentication> <authorization>
<allow users="*" /> <!-- 允许所有用户 -->
<!-- <allow users="[逗号分隔的用户列表]"
roles="[逗号分隔的角色列表]"/>
<deny users="[逗号分隔的用户列表]"
roles="[逗号分隔的角色列表]"/>
-->
</authorization>