views:

216

answers:

2

I have some pages designed by someone else as simple HTML that I need to dump into my MVC application.

Not surprisingly the images are stored in a local /images directory.

I'd like to be able to serve the images up from the Views directory where the main view pages are.

I'd rather do this than make it its own virtual directory, but I'm not sure if this is really easy or possible. In the future i forsee having to add 'mvc' components (such as RenderPartial or Html extension code) into the pages so I'd prefer the pages to be part of my application instead of just tagging along in their own virtual directory.

Main path:

 http://example.com/microsite/

Images path:

 http://example.com/microsite/images

I'd want microsite/images to map to Views/Microsite/images if possible.

Or if theres a way to create a 'pseudo' virtual directory in the application I'd rather do that than rely on having to set up the virtual directory from within IIS - but I don't think thats possible.

I tried using something like this, but that doesnt work of course because this isnt actually mapping, but just an ignoring of a route:

 routes.IgnoreRoute("microsite/images/{*pathInfo}");
+1  A: 

It sounds like you might benifit from a MVC 2 feature called "Areas". Phil Haack posted on this new feature.

Chuck Conway
i did wonder about that. i am actually experimenting with 2.0 now but even within a single area I'm not sure how you can serve images from the views directory
Simon_Weaver
+1  A: 

Using <img src="<%=Url.Content("~/my/path/to/images/picture.png")%> should resolve no matter what the actual location of the image. Instead of "~/Content/Images", you'll point to "~/Views/Products/Images/product1.png", or something close to that.

There is no need to modify routes with this implementation.

Jarrett Meyer
i was hoping to be able to get it working just leaving <img src="images/picture.png"> so that the person working on the microsite doesnt need any MVC training and can run it inside apache or whatever theyre using without needing to train them
Simon_Weaver