Rip's Domain MVC images from virtual directory

Posted in MVC by rip747 on September 25, 2012

Here is something that stumped us for a while. At work we were converting a legacy asp site over to MVC. The old site got it images from two virtual directories mapped to a file share on another server. When we went to deploy the new site, we created the virtual directories, however we kept on getting error when trying to access any of the images!

Turns out that in order to use a virtual directory under as MVC application, you need to make sure that after you create the virtual directory, you convert it to an application.

Apparently without doing this, IIS thinks that the virtual directory is part of the MVC application and when requests to the virtual directory come it, the MVC routing takes over which was causing the error. By converting it to an application, you remove the virtual directory from the MVC application entirely.