Getting Same Request.UrlReferrer
I have one page Result.aspx.this is main page of my website. There are many images of proudc开发者_JAVA百科ts in this pages.
When i click on image of product, it is redirected to DetailResult.aspx
Image Code is here:
<td>
<a href="<%#Eval("DetailsURL")%>">
<asp:Image runat="server" ID="ImgThumb" Width="115" Height="81" />
</a>
</td>
Now, On load event of DetailResult.aspx, i am getting runtime error for NullReferenceException(or any).
To handle runtime error, i have configured web.config with CustomErrors tag
CustomErrors Tag Code here:
<customErrors mode="On" defaultRedirect="~/Result.aspx?RunTimeError=1">
</customErrors>
So the runtime error of DetailResult.aspx page redirects to Result.aspx. In this case, on Result.aspx when i try to get previous page URL using Request.UrlReferrer, i am getting its value "Result.aspx" instead of "DetailResult.aspx"
UrlReferrer is an http header sent by your browser. If you click a link on Result.aspx, and you end up on Result.aspx?RunTimeError=1, your browser (not unreasonably) decides that the UrlReferrer should be set to the page that initiated the action. That there was a 302 redirect from DetailResult.aspx is not particularly important. If you would like to know the page that caused the error, you could configure an errorpage that will append this information to the querystring before redirecting.
Menno
精彩评论