Azure ASP.NET MVC Web.Config Deployment Problem

We are developing an ASP.NET MVC web application that will be hosted on Windows Azure. We implemented the application several times during the development process without any problems. Actually it was pretty amazing how smooth the process is. Then, when we went to deploy the beta application, we always got 403 Access Denied errors when we tried to go to the base URL of the site. If we tried to go to any of the different controllers and site actions after that, we would get 404. Could not find errors in the resource.

Another weird thing we noticed is that we defined the authentication redirect page as / Access / SignIn, and not the default account / login. Everything worked perfectly on the development machine, and we were redirected to / Access / SignIn, but when we published to Azure, we saw that we were redirected to / Account / Login. This made us think that there was a problem with the web.config file.

We turned on Remote Desktop in the Azure deployment and looked at the web.config file to find out that it is almost completely empty! The only setting there was machineKey. We manually copied the web.config file from one of our development machines to the Azure virtual machine instance, and it all started from that moment.

What in the world will a deployment destroy a web.config file? And how can we prevent this because we are not going to update the web.config file manually each time the update is deployed?

+2
source share
1 answer

I often solve these problems by looking at the contents of the .cspkg file. This allows me to avoid waiting for the download and initialization of the Azure package. Here are the steps to view the contents of .cspkg:

  • Go to the /bin//app.publish folder
  • Rename the .cspkg file to .cspkg.zip.
  • Open .cspkg.zip. You will find the .cssx file (which is really a zip file) for each project referenced by the Azure project.
  • Extract the .cssx file that you want to check and rename to .cssx.zip
  • .cssx.zip . WorkerRoles . WebRoles sitesroot.
+2

All Articles