Windows Server 2008 R2, ASP.NET 4.0, IIS 7+ 64 bit mode issue

Jun 20, 2011 at 1:20 PM
Edited Jun 20, 2011 at 1:25 PM

There seems to be an issue with this component running under the following specification:

1. Windows server 2008 R2
2. IIS 7+
3. ASP.NET 4.0
4. ASP.NET MVC 2
5. Application Pool Running in 64 bit mode 

The error message received:

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

This is down to the fact that either: 

1. Reflection permission on the assembly is denied when getting the calling assembly (should not be the case in full trust environments)
2. The calling assembly passed in not what is expected
3. Something else very weird 

See the following urls for more information.

http://stackoverflow.com/questions/6081056/asp-net-deployment-issues-not-working-in-release-mode
http://stackoverflow.com/questions/2374957/asp-net-mvc-on-iis-7-5

I initially had to run the application in 32 bit mode to get it to work but with some perseverance I found that if I modified the RegisterUrlFromAttributes method to use the following code it works.

public static void RegisterUrlRoutesFromAttributes(RouteCollection routes)
{
   // Enumerate assembly for UrlRoute attributes.
   List<MapRouteParams> routeParams = new List<MapRouteParams>();
   AppDomain.CurrentDomain.GetAssemblies()
      .ToList()
      .ForEach(assembly => routeParams.AddRange(GetRouteParamsFromAttributes(assembly)));

..

http://www.avantprime.com/