2

We are developing an ASP.NET MVC web app that will be hosted on Windows Azure. We have deployed the application a few times during development without any problems. It was actually quite surprising how smooth the process went. Then, when we went to deploy the app for beta testing we kept getting 403 Access Denied errors whenever we tried to navigate to the base url of the site. If we tried to navigate to any of the various Controllers and Actions of the site thereafter we would get 404 The resource could not be found errors.

The other strange thing that we noticed is that we had defined the authentication redirect page to be /Access/SignIn rather than the default Account/Login. Everything worked fine on the development machine and we were redirected to /Access/SignIn but when publishing to Azure we saw we were being redirected to /Account/Login. This made us think there was an issue with the web.config file.

We enabled remote desktop on the Azure deployment and took a look at the web.config file only to find out that it was almost completely empty! The only setting in there was the machineKey. We manually copied the web.config from one of our development machines up to the Azure virtual machine instance and everything started to work from there on.

What in the world would make the deployment wipe out the web.config file? And how can we prevent this from happening as we aren't going to be able to update the web.config file manually every time we deploy an update?

Nick Olsen
  • 6,299
  • 11
  • 53
  • 75
  • Are you performing any config transformations when building the cspkg? – Jonathan McIntire Mar 05 '12 at 16:29
  • I'll be honest I didn't even know that was possible! Unless we did something accidentally I'm not ware of any transformations taking place. Just to confirm, if no transformations are defined, the web.config should be deployed to Azure as is correct? – Nick Olsen Mar 05 '12 at 16:38
  • You're correct. The web.config should be copied as is. If you navigate to the /bin//app.publish folder you should find the .cspkg file that's uploaded to Azure. You can view the contents of the file by giving it the .zip extension. In the cspkg, each project referenced in the Azure project will have its own zip file (you'll have to add the .zip extension for the project zip as well). This will allow you to see the contents of the Azure package without having to upload to Azure. This can help solving these sort of problems. – Jonathan McIntire Mar 05 '12 at 17:01
  • 1
    Thanks for the tips! That led me right to the solution. Turns out the web.config file wasn't even being included in the deployment package. Somehow the BuildAction of the web.config file got changed from Content to None... No idea how that happened. If you provide some sort of answer for this question I can give you credit. – Nick Olsen Mar 05 '12 at 17:49
  • Thanks Nick! Glad to hear you were able to solve your problem. – Jonathan McIntire Mar 05 '12 at 18:06

1 Answers1

2

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

  1. Navigate to the /bin//app.publish folder
  2. Rename the .cspkg file to .cspkg.zip.
  3. Open .cspkg.zip. You will find a .cssx file (which is really a zip file) for each project referenced by the Azure project.
  4. Extract the .cssx file you wich to inspect and rename it to .cssx.zip
  5. Open the .cssx.zip and look around. For WorkerRoles, check out the approot folder. For WebRoles, check out the sitesroot folder.
Jonathan McIntire
  • 2,665
  • 23
  • 26