Using Redirect and EndResponse in Azure Crashes the AppFrabric Load Balancer

Now that CitySourced is on Microsoft’s Azure cloud services, I’m a huge fan of what it offers both developers and startup companies. That being said, I wanted to put a quick note out there about a fix to a bug I found to help spread the knowledge I’ve gained getting into the nuts and bolts of it. With CitySourced, the original application was written in .NET (C#, 3.5 Framework), so the port was relatively simple. Once we started playing around with it though, the development app fabric kept crashing on us for no apparent reason. I searched Google (and Bing) and came up with nothing. Upon closer inspection of the code, it appears that if you redirect and specify the “EndResponse” flag as true, the app fabric bombs. So, in summary:

This BOMBS -> Response.Redirect(“~/my-new-url”, true);

This WORKS -> Response.Redirect(“~/my-new-url”, false);

I guess Azure doesn’t like ending the response prematurely. Luckily, we had abstracted any and all redirects to a utility class (eg, ContextUtil). So we updated our code in one place and viola! Our code worked perfectly.

I’ll be doing a pretty in depth post on our complete migration, what I like, what I didn’t like, etc. Stay tuned!

Leave a Reply

Your email address will not be published. Required fields are marked *