views:

800

answers:

2

I have a very nice MVC Beta application developed using VS2008 on a win2008 server. My troubles began when I attempted to deploy it to an IIS6 virtual directory. After installing the MVC Beta on the target win2003 server box I was able to get the application to display from a virtual directory, but all images and css attributes are missing. The place holders suggest the images should be located at the root web site rather than the virtual directory the application is running out of.

Actual path:

http://localhost/Content/images/<myimage>.png

Rather than:

http://localhost/<virtualdirectory>/Content/images/<myimage>.png

If I install the application in its own web site (Root) everything works fine. I can duplicate this in VS2008 by setting the web properties to "Use Visual Studio Development Server"/Specific Port / and add a virtual path.

I can also duplicate this by setting web properties on the project to "Use Local IIS Web Server" and creating a virtual directory.

There is something obvious I am missing regarding mvc url routing. Any guidance here would be appreciated.

+5  A: 

How have you referenced the images? They should start "~/" to mean "app root" ("/" is "site root") - i.e. "/Content/images/myimage.png".

However, some controls will send this to the client without substituting the virtual path; for a related thread (talking about js, but the concept is the same), see here (includes a simple solution / example approach).

Also - is the virtual an app? cog icon...

Consider a <base href...> tag in the master page (to the app root)

Marc Gravell
A: 

refer to this post on how to dynamically add page resources in a way that separates the real path from a relative list of resources (imeges/css/js files, etc): http://stephenwalther.com/blog/archive/2008/08/23/asp-net-mvc-tip-36-create-a-popup-calendar-helper.aspx

cottsak