What should I do when on Azure Web Role I get "HTTP Error 401.2 - Unauthorized. You are not authorized to view this page due to invalid authentication headers"
This post is dedicated to a simple but annoying issue that can appear when you are developing a ASP.NET MVC Application. When I run my web application on my local machine, directly from Visual Studio, my web sites works perfectly. When I deploy it on a Web Role I get " HTTP Error 401.2 - Unauthorized. You are not authorized to view this page due to invalid authentication headers " The same problem can appears if you deploy on on-premises servers, but in general this problem pop-ups on Web Roles. Not because a web role is different (it has the same layers as a web server -OS and IIS), but because people that are working with cloud solutions forget about infrastructure layers. If we are reading the error message we can identify some possible root causes. But basically it seems that the user that is trying to access the page is not authorized. But why it is working on the development machine from Visual Studio? Simple, in general the developer is also the admin on the mach...