Krishh
Krishh

Reputation: 4231

Get "Redirected from" URL

I have a page A and clicking on a link it gets redirected to page B. From page B is it possible to get the url of Page A. Can anyone explain me how I could get this using C#?

Upvotes: 0

Views: 864

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039498

You could use the UrlReferrer property of the request. So on Page B:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        string referrer = Request.UrlReferrer;
        // TODO: do something with the referrer
    }
}

This being said, the HTTP Referrer header can be spoofed so absolutely do not rely on this to implement any kind of security.

Upvotes: 4

Related Questions