3

I have an ASP.NET MVC 2 application running fine on both IIS7 and the VS Web Development server. I recently added areas to the site and these too work fine on IIS7 and the VS Web Development server.

However when I deploy this site to an IIS6 test server running win2k3, the areas no longer work. All of the paths using the default routes for the rest of the site work fine (eg. /Home/Index/), however when I navigate to an area (for example /Admin/Users/Index/) i get an HttpException:

System.Web.HttpException: Server cannot access application directory 'C:\InetPub\MobileWeb\Admin\'. The directory does not exist or is not accessible because of security settings.

C:\InetPub\MobileWeb\ is the root directory of my site. If I add an Admin directory to the file system, I then get various assembly loading errors, but I'm pretty sure this won't happen if I can get the areas to work correctly.

All I did (and have done many times before) to enable ASP.NET MVC on IIS6 was to add a wildcard handler that maps to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll and unchecked "verify that file exists"

Our build server automatically deploys this code by compiling a VS 2008 Deployment Project, and then copying the output to our test server. I found this article that has a similar problem, but if i'm understanding the resolution correctly, it did not working me.

Is there something unique that i need to do get areas working on IIS6?

Update - Here's the full stack trace:

[HttpException (0x80004005): Server cannot access application directory 'C:\InetPub\MobileWeb\'. The directory does not exist or is not accessible because of security settings.]
   System.Web.HttpRuntime.EnsureAccessToApplicationDirectory() +8932031
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags) +87

[HttpException (0x80004005): Server cannot access application directory 'C:\InetPub\MobileWeb\'. The directory does not exist or is not accessible because of security settings.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8894095
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259

Update I've tried publishing to the test server using both the VS2008 publish website and VS2008 Web Deployment project (and manually copying files over) - both have the same issue.

jaminto
  • 3,895
  • 3
  • 32
  • 36
  • Does a non-area route work even if it's more complex than the default stuff? E.g. `/iis6/die/already/666`? – bzlm Oct 03 '11 at 21:37
  • What have you found from route debugging? Does it "find" the route? – Nick DeVore Oct 04 '11 at 14:52
  • @bzlm - i really don't have any routes more complicated than the standard /controller/action/id?url_params=stuff and they all work – jaminto Oct 06 '11 at 04:03
  • @NickDeVore route debugging doesn't work for the area routes, i get the same "server cannot access application directory" error as above - it's not even executing the route debugging code – jaminto Oct 06 '11 at 04:09
  • I know you don't have such routes. I think you should make them, to help pinpoint the problem. :) – bzlm Oct 06 '11 at 06:34
  • I added this route: {controller}/{action}/{id}/{var1} and it works fine.... – jaminto Oct 06 '11 at 16:11

2 Answers2

0

Seems like it is directory level permissions on that folder. I'm assuming the "Everyone" group has read access to that directory. Is there some account that is denied access to that directory?

Nick DeVore
  • 9,748
  • 3
  • 39
  • 41
  • c:\InetPub\MobileWeb If the IIS process can't access it, then that is the kind of error you can get – Nick DeVore Oct 03 '11 at 20:22
  • But then why does he get compiler errors in the new directory? Something is not right. Its not that far fetched for it to be permissions, especially considering that it is the new directory that has the problems. – Nick DeVore Oct 03 '11 at 20:28
  • There is no "new directory" according to the question, just a web app recently deployed to IIS 6. – bzlm Oct 03 '11 at 20:29
  • I'm basing this off the error message. It is saying it can't access that folder. If my answer is wrong, post your suggestion. – Nick DeVore Oct 03 '11 at 20:34
  • @Nick DeVore - that's the root of the issue. there is no Admin folder and there should not be - it's simply part of the route that MVC is supposed to use to figure out the MVC Area where the controller and action can be found. – jaminto Oct 03 '11 at 21:04
0

It's fairly unlikely that you had the same issue as I did but in case you did here's my solution:

I had added a new "admin" area and was getting this error whenever I went to any page in the new area however, all of the other areas were working fine.

This new area replaced an old web forms application which was hosted on a virtual site below the main application in IIS. The root of the virtual site was site.com/admin/.

The old application files had been removed from the file system however the IIS site was still active. Whenever a request came in for /admin/... it was handled by the old application which (correctly) couldn't find the application root so it threw an exception.

Adam Flanagan
  • 3,052
  • 23
  • 31