Note that there are some explanatory texts on larger screens.

plurals
  1. POResponse.Redirect doesn't work in .Net 4.5
    text
    copied!<p>I am calling response.redirect after verifying the login credentials this all works fine in .net framework 3.5 but when I upgrade to .net 4.5 nothing happens. It stays on the same page.</p> <p>I have tried various permutations</p> <pre><code>System.Web.HttpContext.Current.Response.Redirect("/"); System.Web.HttpContext.Current.Response.Redirect("/", false); System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest(); </code></pre> <p>nothing seems to work I have put a try catch around it and I don't get any exceptions when using false.</p> <p>The code is being called off of an asp:button onClick event. during the click event I check to see if the credentials were correct if they are I perform the login setting session variables ... and redirect them to the appropriate landing page for their role.</p> <p><strong>More Info</strong> I have boiled my problem down to a basic scenario. In the following scenario both buttons call the same function btnTemp_Click which calls Response.redirect. In the case of the asp:button it works in the case of the HTML5 button it doesn't. In both cases the breakpoint on the response.redirect is executed. </p> <pre><code>&lt;asp:Button ID="btnTemp" Text="Test Redirect" runat="server" OnClick="btnTemp_Click" /&gt; &lt;button id="btnTmp2" runat="server" onserverclick="btnTemp_Click" &gt;button to Redirect&lt;/button&gt; protected void btnTemp_Click(object sender, EventArgs e) { HttpContext.Current.Response.Redirect("http://www.google.com", false); } </code></pre> <p>Something else that is weird after clicking the <em>button</em> the <em>asp:button</em> no longer works</p> <p>If I create a brand new Web application and have nothing in it but these two buttons it works for both. So I must have some code that is doing something somewhere that the onserverclick hits but the onclick doesn't.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload