-
今日学习
2005-12-04
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://zhangchenliang.blogbus.com/logs/1666078.html
今天终于搞定了表单验证。虽然说技术含量不高,但是毕竟是自己搞定的。心理还是很高兴!
<configuration>
<system.web>
<authentication mode = "Forms">
<forms name="ProgAspNetCookie" loginUrl="csLoginForm.aspx" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>DEMO页面
<%@ Page Language="vb" %>
<script runat="server">
sub btn_Click(ByVal Sender as Object, _
ByVal e as EventArgs)
if FormsAuthentication.Authenticate(txtUserName.Text, _
txtPassword.Text) then
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, _
false)
else
lblMessage.Text = "Not Authenticated:<br>" & txtUserName.Text & _
"<br>" & txtPassword.Text
end if
end sub
</script>Example 19-8. Login form using SetAuthCookie in VB.NET
<%@ Page Language="vb" %> <script runat="server"> sub btn_Click(ByVal Sender as Object, _ ByVal e as EventArgs) if FormsAuthentication.Authenticate(txtUserName.Text, _ txtPassword.Text) then FormsAuthentication.SetAuthCookie(txtUserName.Text, _ false) Response.redirect("default.aspx") else lblMessage.Text = "Not Authenticated:<br>" & txtUserName.Text & _ "<br>" & txtPassword.Text end if end sub </script>
收藏到:Del.icio.us







