且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在复制URL并粘贴其他浏览器时重定向到登录页面

更新时间:2022-11-18 12:57:28





正确使用身份验证,并在web.config文件中将登录页面设置为login.aspx。你不用担心。 Asp.net身份验证将自动执行。请参阅以下链接:

来自自定义对ASP.NET Forms身份验证的身份验证 [ ^ ]

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

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.authenticate.aspx [ ^ ]

http://***.com/questions/2686946/asp-net-authentication-login-and-logout-with-browser-back-button [ ^ ]



一切顺利。

--AK
Hi,

Use authentication properly and set the login page to login.aspx there in web.config file. You don't need to worry. Asp.net authentication will do it automatically. Refer these links:
From Custom Authentication to ASP.NET Forms Authentication[^]
http://msdn.microsoft.com/en-us/library/ms178329.aspx[^]
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.authenticate.aspx[^]
http://***.com/questions/2686946/asp-net-authentication-login-and-logout-with-browser-back-button[^]

All the best.
--AK


if ((HttpContext.Current.Request.UrlReferrer == null))
{
    Response.Redirect("Default.aspx");
}


如果我有project.aspx和login.aspx



在你的project.aspx.cs上页面加载

只需写一下



if((HttpContext.Current.Request.UrlReferrer == null) )

{

Response.Redirect(login.aspx);

}



这会将你重定向回登录页面。

希望这能解决你的问题。



Adejumo
"If I have project.aspx and login.aspx"

On your project.aspx.cs Page Load
simply write

if ((HttpContext.Current.Request.UrlReferrer == null))
{
Response.Redirect("login.aspx");
}

This will redirect you back to Login page.
Hope this solves your problem.

Adejumo