Monday, 26 August 2013

URL where user come from ASP.Net but have NULL

URL where user come from ASP.Net but have NULL

I want to know-from what url user come from. So, i use
Uri MyUrl = Request.UrlReferrer;
But when i get only null value from MyUrl:
I have two projects-first is my aspx page, second- redirects to this first
project-page with GET parameters. But when second project redirect to
first project- i have :
Object reference not set to an instance of an object.
My first project so simple:
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("http://localhost:54287/go.aspx?id=DEFAULT");
}
Second project:
protected void Page_Load(object sender, EventArgs e)
{
//Request.ServerVariables('http_referer');
// Request.ServerVariables;
string id = Request.QueryString["id"];
if (id != null)
{
Uri MyUrl = Request.UrlReferrer;
Console.WriteLine(MyUrl);
Response.Write("Referrer URL : " + MyUrl.AbsolutePath);
}
}

No comments:

Post a Comment