会话存在时重定向到默认页面 [英] Redirect to default page when Session exists

查看:80
本文介绍了会话存在时重定向到默认页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







在我的登录页面中,我使用的是表格认证

Hi,


In my login page I am using Forms Authentication

FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(30), true, "");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
       ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);



当我成功登录并打开另一个标签并输入URL


When I do a successful login, and opened another tab and I type the URL

http://localhost:53382/Login.aspx





我想重定向到默认值页面

注意:我正在使用Site.master页面。



请帮助我。在此先感谢



I want to redirect to default page
Note: I am using Site.master page.

Please help me. Thanks in advance

推荐答案

您好,



我找到了解决方案。



我在登录页面的页面加载事件中检查会话是否为空。



如果不为null,重定向到默认页面
Hi,

I have found the solution for this.

I am checking the session is null or not in page load event of login page.

If is not null, redirect to default page


这篇关于会话存在时重定向到默认页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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