javascriptjqueryhttpmoduleihttpmodule

window.location.href not working after Response.End()


I tried all the answers from other similar questions but did not solve my problem.

I have an AJAX call to a HttpModule. Inside the HttpModule, I ended the request using

Response.End()

Then, on the .done() on AJAX, I did a redirect

window.location.href = <valid location>; 

To verify that window.location.href works on the browser, I tested it on a blank browser and it worked!

There may be something that prevented the window.location.href from executing after the premature end of the Response. Can anyone help me solve this?


Solution

  • It seems like Response.End is blocking the redirection in Javascript.

    I have tried using the suggested fixes from other threads (e.g. SessionTimeout and adding return false after the redirect), but both did not work.

    As a work-around, instead of using window.location.href, I did a window.location.reload(). This fixed my problem.

    I still welcome ideas and suggestions.