日期:2014-05-18  浏览次数:20475 次

如何获得用户前一次的请求Url地址?
就是比如我要访问a.aspx然后由于没有登录,重定向到login.aspx了,然后我登录以后,怎么获取他之前是请求a.aspx的地址的?

------解决方案--------------------
href = Request.Url.AbsoluteUri.ToString();
if (Request.Cookies[ "admin "] == null)
{
Response.Write( " <script> alert( '连接超时,请重新登陆! ');location.href= 'Login.aspx?url= " + href + " '; </script> ");
}


//获取当前URL判断指定跳转
if (href == null)
{
Response.Redirect( "index.html ");
}
if (href != null)
{
Response.Redirect( " " + href + " ");
}
------解决方案--------------------
转到登录的时候先url吧上张网页的网址一起传过来

登录以后就可以跳转了~!
------解决方案--------------------
就是比如我要访问a.aspx然后由于没有登录,重定向到login.aspx了,然后我登录以后,怎么获取他之前是请求a.aspx的地址的?

=========

当访问 a.aspx 的是,重定向的的时候将 a.aspx 传倒 login.aspx 都是这样的处理的啊

// a.aspx.cs

if(没有权限) {
Response.Redirect( "login.aspx?returnUrl= " + Request.RawUrl);
}


//login.aspx.cs
if(登录登录成功) {
if(!String.IsNullOrEmpty(Request.QueryString[ "returnUrl "]) {
Response.Redirect(Request.QueryString[ "returnUrl "]);
} else {
Response.Redirect(默认页面);
}
}
------解决方案--------------------
使用Request.UrlReferrer,获得转跳前一页面的URL,登入成功后,再转跳。