开发者

How do I retrieve the referrer page url once a custom error page is returned

I'd like to capture the http referrer url following the rendering of a custom error page.

I have this set in my web.config

<customErrors mode="On">
  <error statusCode="500" redirect="/StaticError.aspx" />
</customErrors>

In the OnLoad(EventArgs e开发者_运维百科) event -- I'm trying to do this, but it appears to be too late.

this.txtReferrer.Text = Request.UrlReferrer.ToString();

Is it possible to capture the referrer url?


On your custom error page (/StaticError.aspx), Request.UrlReferrer will be the page that referred/posted to the page that is erroring. If your first request to the website is the erroring page, it will be blank, as there is no referrer.

If you are looking for the page that actually errored, it will be posted to the query string when directed to your custom error page.

VB.NET

this.txtReferrer.Text = Request.QueryString("aspxerrorpath")

C#

this.txtReferrer.Text = Request.QueryString["aspxerrorpath"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜