如何创建表单身份验证 [英] how to create Forms Authentication

查看:95
本文介绍了如何创建表单身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当登录凭据正确时,我会有一个登录页面,如果我复制并粘贴applyleave.aspx的网址,它将重定向到页面applyleave.aspx,它应该重定向到登录页面而不是applyleave.aspx,如何操作

感谢

Hi
I have a login page when the login credentials are correct it will redirect to a page applyleave.aspx if I copy and paste the url of applyleave.aspx it should redirect to the loginpage and not to the applyleave.aspx, how to do it

Thanks

推荐答案

检查以下有关实现表单身份验证的教程:


http://msdn.microsoft.com/en-us/library/xdt4thhy.aspx [ ^ ]
check the following tutorial on implementing forms authentication:


http://msdn.microsoft.com/en-us/library/xdt4thhy.aspx[^]


在登录页面中

In Login page

if (authentication success)
{
Session["UserStatus"] = UserName.Text;
Server.Transfer("~/applyleave.aspx");
}
else
{
Response.Write("Retry");
}



在applyleave.aspx
页面加载事件



In applyleave.aspx
On page load event

if (Session["UserStatus"] != null)
{
}
else
Server.Transfer("~/applyleave.aspx");


这些可能对您有帮助

http://support.microsoft.com/kb/301240 [ http://www.codedigest.com/Articles/ASPNET/112_Implementing_Forms_Authentication_in_ASPNet_20.aspx [ ^ ]
These may help you

http://support.microsoft.com/kb/301240[^]

http://www.codedigest.com/Articles/ASPNET/112_Implementing_Forms_Authentication_in_ASPNet_20.aspx[^]


这篇关于如何创建表单身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆