Search code examples
c#javascriptjqueryasp.net-mvcreferrer

Request.UrlReferrer is not working in IE8 and working fine IE9


I have Close button on my ASP.NET MVC page. I wrote the following code to go back to previous page. It is working fine in IE9 but throwing error in IE8.

 $('#Close').click(function () {
          window.location.href= '@Request.UrlReferrer';

        });

Appreciate your responses.

Thanks


Solution

  • Referer is not required by the HTTP specification, so you can't really rely on it. You can use this though

    $('#Close').click(function () {
      window.history.back();
    });