Response.Redirect issue with Asp.net async
This code will work in a brand new project, but, does not work with a new page in our existing code.
I assume your existing site has already been upgraded to .NET 4.5.
The first thing to check is that httpRuntime.targetFramework
is set to 4.5
. This is not set by default when you upgrade.
Edit from comments:
Another thing to check (just in case) is that Page.Async
is set to true
.
In this case, the solution was to call Response.Redirect("http://www.google.com", false)
, which explicitly passes false
for the endResponse
parameter. The default value of true
is only for backwards-compatibility reasons as described here.