Search code examples
asp.netbuttonback

Back button for my page in asp.net


I used this code in order to hid the errors.

<customErrors defaultRedirect="ErrorServer.aspx" mode="On" />

I want to have back button for my Error page and as the user push the button it goes to the page that the user came from that. It means each time the back URL will be different! How can i add the back button in my page? Thanks


Solution

  • You can check the referring URL on your error page.

    So your front end could have this:

    <asp:HyperLink ID="hypBackLink" Text="Go Back" runat="server" />
    

    And in your Page_Load event:

    if(Request.UrlReferrer != null)
         hypBackLink.NavigateURL = Request.UrlReferrer;