Question about capturing previous page

  • Thread starter Thread starter Hardy Wang
  • Start date Start date
H

Hardy Wang

Hi,
I have a legacy ASP page, in which I have following pieces of JavaScript
to run in order to sending values to a new ASPX page
......
action = "NewVersion/Bridge.aspx";
method='get';
submit();
......

In the new Bridge.aspx, I need to detect which privous page sends out the
request, so I have following codes in my ASPX code behind
Uri refUrl = Request.UrlReferrer;
Trace.Write(refUrl.AbsolutePath);

But system will throw an exception "NullReferenceException: Object reference
not set to an instance of an object." on second line. It looks like ASPX is
unable to detect its previous page if previous one uses form to sends
request.

Any clue how to obtain previous page?

Thanks!
 
Hardy Wang said:
Hi,
I have a legacy ASP page, in which I have following pieces of JavaScript
to run in order to sending values to a new ASPX page
.....
action = "NewVersion/Bridge.aspx";
method='get';
submit();
.....

In the new Bridge.aspx, I need to detect which privous page sends out the
request, so I have following codes in my ASPX code behind
Uri refUrl = Request.UrlReferrer;
Trace.Write(refUrl.AbsolutePath);

But system will throw an exception "NullReferenceException: Object reference
not set to an instance of an object." on second line. It looks like ASPX is
unable to detect its previous page if previous one uses form to sends
request.

Any clue how to obtain previous page?

UrlReferrer will be null if there is no Referrer header in the request.
 
Back
Top