ASP.NET MVC - The Issue with Global.asax and Load Balanced Servers
I was troubleshooting one of the issues where my ASP.NET MVC app was working in DEV environment (Win 2k3 single server) and when moved to Pre-PROD (Win 2k3 load balanced) we started getting 403 Forbidden errors.
There were quite a few possibilities:
- The application was configured to use Windows Authentication with Role Bases Access. Roles were coming from DB. Couple of things we verified at the first glance:
- The security setting for the VD was exactly same as it was in the DEV ( disable anonymous access + Integrated Windows Authentication)
- ASP.NET MVC route map was configured for the IIS VD
- The config settings were same in web.config/machine.config as the DEV environment
- Database was accessible from the Web Server
- The user roles were configured properly
- Now the turn was to verify if there was a difference in files what got staged in two locations:
- We found that in the Pre-Prod environment, Global.asax file was missing. BUT Why???
- We observed that there was a difference in how the deployment was done in DEV vs Pre-Prod.
- In DEV, we used Publish from VS studio and did x-copy of all the content from the published location to the DEV server. It had the Global.asax.
- In PreProd, we x-copied Web Deployment Project’s output. This doesn’t contain Global.asax. So where is the file then?? – we observed that it had a precompiled copy of this file in bin folder and there was Web.Deploy.DLL in there which was additional file if we compare it with the DEV environment.
- As a first step, we added the Global.asax file to the Pre-Prod VD. This resolved the first hurdle. At lease we were reaching till the server request. Thanks to following post for the help:
https://serverfault.com/questions/150973/deploying-asp-net-mvc-to-windows-server-2003
- Now we were getting "error related to conflict on _global.asax type in ASPNET temp file”…
- We cleared all the temp files.
- Recycled app pools/restarted the app pool…
- Still the error was there
- We removed the Web.Deploy.dll.. viola – the app started working..
Good show overall… However – I don’t think the web deploy dll should play a role with existence of Global.asax. I think there is something which is related to some attributes of the build in the web deployment project. Need to figure out. For now – the app is working and we’ve a breather to get going…