Question

I have an ASP.NET MVC application that runs on Windows Azure Website.

All of sudden the website started to redirect homepage URL '/' to itself causing a redirect loop. No change was made in the application at the time of the incident and log files don't contain any suspicious information - just lot of similar requests

2014-01-09 09:00:05 SITE_NAME GET / X-ARR-LOG-ID=581f1d91-727a-4820-a7fa-7c21888b5813 80 - 193.85.68.249 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+5.1;+Trident/4.0;+Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1)+;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) _ga=GA1.2.720579394.1386747761;+ARRAffinity=12ae470da6bd7ab5a7c446a8f29748ba5f73605e7fcd365292d61319cb67336f;+WAWebSiteSID=654ed6b99c9747759561e52c1f2cb0f8 - www.domain.cz 301 0 0 534 1069 31
2014-01-09 09:00:05 SITE_NAME GET / X-ARR-LOG-ID=3ddebc99-c083-4cbf-9bbe-90d755a8b1a0 80 - 193.85.68.249 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+5.1;+Trident/4.0;+Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1)+;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) _ga=GA1.2.720579394.1386747761;+ARRAffinity=12ae470da6bd7ab5a7c446a8f29748ba5f73605e7fcd365292d61319cb67336f;+WAWebSiteSID=654ed6b99c9747759561e52c1f2cb0f8 - www.domain.cz 301 0 0 534 1073 0

When I restarted the Azure website everything went back to the normal. The same problem occurred for the third time, so it probably isn't just a 'hiccup' of the server.

Can anybody help me with the problem diagnostic? I am kind of lost, because neither server logs nor application logs contains any useful information.

OTHER TIPS

You can use Application_BeginRequest to have the routing globally between non-www url to www url.

 protected void Application_BeginRequest(Object sender, EventArgs e)
 {   
   if (!Request.Url.Host.StartsWith("www"))
   {
      UriBuilder builder = new UriBuilder (Request.Url);
      builder.Host = "www." + Request.Url.Host;
      Response.Clear();
      Response.StatusCode = 301;
      Response.StatusDescription = "Moved Permanently";
      Response.AddHeader("Location", redirectUrl);
      Response.End();
   }
 }

I have already answered over here

but because I crossed this article during my investigations I wish to share here also ...

I experienced this issue with one of my Azure web apps which was serving traffic over http.

The solution for me was to disable the affinity cookie.

If I had an app where maintaining user session on 1 server was required I would have to re-enable the affinity cookie, but because that caused me (intermittent) problems I would also force all traffic to https as that seems to be a more successful set up to use with the Affinity cookie.

this link was really helpful and great background info: https://azure.microsoft.com/en-us/blog/disabling-arrs-instance-affinity-in-windows-azure-web-sites/

I realize that this is old. But in my case this was due to an error in the code.

To get the real error to show I had to change this in the web.config

<customErrors mode="RemoteOnly" defaultRedirect="/Error/Index" />

To this

<customErrors mode="Off" />

It then showed me that

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top