Rip's Domain

ASP.net MVC images from virtual directory

Posted in ASP.net 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 ASP.net 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 ASP.net error when trying to access any of the images!

Turns out that in order to use a virtual directory under as ASP.net 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 ASP.net MVC application and when requests to the virtual directory come it, the ASP.net MVC routing takes over which was causing the error. By converting it to an application, you remove the virtual directory from the ASP.net MVC application entirely.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: