[英](C#-ASP.NET-REDIRECT-LOGIN) how to get the url before redirecting the page? In login method
how to get the url before redirecting the page? 重定向页面前如何获取网址?
Example: in A.aspx page has a link that redirects to page b.aspx, and that in "pageload" on page b.aspx I need to grab the link from the previous page: A.aspx. 示例:在A.aspx中,页面具有重定向到页面b.aspx的链接,而在b.aspx页面中的“页面加载”中,我需要从上一页:A.aspx中获取链接。
The scenario is: 该方案是:
When the timeout expires I need to redirect the user to the login page again, but I need save the url that it was accessing, because when he login again I need redirect it to the same page 超时到期后,我需要再次将用户重定向到登录页面,但是我需要保存它正在访问的URL,因为当他再次登录时,我需要将其重定向到同一页面
(C#-ASP.NET-REDIRECT-LOGIN) how to get the url before redirecting the page? (C#-ASP.NET-REDIRECT-LOGIN)如何在重定向页面之前获取URL? In login method
登录方式
Ty. 泰
Edit 编辑
***if (Page.Request.RawUrl != null && !Page.Request.RawUrl.ToUpper().Equals("/DEFAULT.ASPX"))
{
cookie.Value = Page.Request.RawUrl.ToString();
cookie.Expires = DateTime.Now.AddSeconds(SessionLengthMinutes * 2);
Response.Cookies.Add(cookie);
}***
I use this! 我用这个!
Save the link in a session object and then redirect the user. 将链接保存在会话对象中,然后重定向用户。 On successful login retreive the value form session object.
成功登录后,检索值表单会话对象。
Session["PathBeingAccessed"] = "www.xyz.com"; Session [“ PathBeingAccessed”] =“ www.xyz.com”;
if (Page.Request.UrlReferrer != null)
{
Response.Redirect(Page.Request.UrlReferrer.ToString(),false);
}
On Login: 登录时:
if(Session["PathBeingAccessed"]!=null)
{
Response.Redirect(Session["PathBeingAccessed"].toString();)
}
Be carrefull it's a big security issue if the UrlReferrer is not on same web site; 要小心,如果UrlReferrer不在同一网站上,这将是一个很大的安全问题。 I think you need to check url before (domain or whaterver else)
我认为您需要先检查url(域或其他)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.