如何在URL重定向中获取调用URL

时间:2012-05-18 22:39:02

标签: c# asp.net url-rewriting asp.net-3.5

我在ASP.net中使用URL重定向,就像这个页面

http://xyz:6477/BoxOffice/Events/353454

重定向到>>>

http://xyz:6477/BoxOffice/Events.aspx?EventId=353454

我想在活动页面的页面加载中获取URL

http://xyz:6477/BoxOffice/Events/353454

1 个答案:

答案 0 :(得分:-2)

使用

//To get referrer
//in C#
Uri MyUrl = Request.UrlReferrer; 

//in vb
Dim MyUrl As Uri = Request.UrlReferrer 

//To get current
//in C#

Uri currrenturl = Request.Url;
//in vb
Dim currentUrl As Uri = Request.Url

如果您使用路由,请使用

    //c#
    string ref = Request.UrlReferrer.LocalPath;