如果用户已经登录,则在与ASP .NET C#相同的浏览器中重定向到主页 [英] Redirect to Home page if user already logged in, in same browser asp .net c#

查看:73
本文介绍了如果用户已经登录,则在与ASP .NET C#相同的浏览器中重定向到主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个应用程序,如果用户在浏览器的一个选项卡中登录了网站,并且在第二个选项卡中打开了应用程序,则他不应重定向至登录页面,而应重定向至主页.就像asp.net C#中的Facebook或yahoomail一样

请帮助

解决方案

将您的主页设置为站点URL中的默认页面,并编写用于在页面加载中检查身份验证的代码,如果用户未登录



一种方法是

步骤1)在登录页面的登录时间上为登录用户分配一个会话变量

第2步)检查是否在每个页面上加载了上述会话变量(检查会话变量是否为null)

步骤3)在登出时为会话变量分配空值

pchindhade,

如果正确使用会话,就不会出现此类问题.
有关详细信息,请单击下面的链接
点击我
任何其他查询都只需发表评论即可.
祝你玩得开心!!!


I want to make application that if user in logged in the web site in one tab of browser and if he open application in second tab than he should not redirect to login page but he should redirect to Home page. just like Facebook or yahoomail in asp.net C#

please help

解决方案

Set your home page is the default page in site URL and write code for checking authentication in page load, This will redirect your Home page to login page if the user not logged in



One way of doing this is

Step 1) Assign one session variable with login user on the log in time in login page

Step 2) check that above session variable on each pages page load (Check session variable is null or not)

Step 3) Assign null to session variable on log out


Hi pchindhade,

If you use the session properly,you don''t get such problems.
For details click below link
Click me
any more queries just place a comment.
Have a good time!!!


这篇关于如果用户已经登录,则在与ASP .NET C#相同的浏览器中重定向到主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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