views:

152

answers:

4

Hello,

I have reading posts all night looking for an answer to my issue and haven't found anything that works for me yet. I am sure there is a simple way to do this but I haven't been able to discover it yet.

Details: MVC 2 Preview Asp.net 3.5 sp1 framework VS 2008 C# web application Windows Server 2008 IIS 7

I have the application running well through VS 2008 no problem. When I hit the play to run in debug mode it starts the ASP.NET Development Server the application loads fine and works as expected, great!

When I publish the application locally or to my web server both on IIS 7 the application doesn't run correctly. Some of the icons are missing and the google maps map is missing. When I view the source it appears correct at first glance, but I can see the paths to the images are looking for the MVC paths and it isn't finding them. It appears the app is running as a regular asp.net app and not an mvc app, maybe?

I also tried to just hit the full source code locally on localhost and the exact same issue is present.

So, I guess my question is how do I deploy a MVC application to run the same in IIS as it does through the development server.

Any help on this is greatly appreciated!

Simon.

PS The environments are clean and pretty much out of the box.

A: 

@user68137 is correct in saying that you need to use relative paths for the images.

I got caught out on this one too, and here's my previous SO question about it...

In short, you need to do something like this...

 <img src='<%= Url.Content( "~/Content/Images/banner.jpg" ) %>' alt="Banner" /> 

Hope this helps!

Brett Rigby
A: 

I had the relative paths set, but what I didn't realize is when I deployed it to the server it went to wwwroot\subsite... I had the relative paths set to src="....\image.jpg" to get back to the root of the site. My error was that if the site is not in the root then the subsite drills back to the root to find the images and of course doesn't find them. Same thing was happening with the JS files. I used the Url.Content and it worked great! problem solved!

The interesting this is when running through the VS dev server with a subsite it still worked well and found the paths even though it shouldn't have. VS dev server <> IIS

Thanks for your help on this!

Simon.

Simon
A: 

Once you know the virtual path to the location you are deploying the project to, you should go into the project configuration in Visual Studio and add it to your project. This way the visual studio development server will use the same path structure as the deployment server. This will save you countless hours of work when deploying.

John
A: 

When you run your website through Visual Studio, every single request gets processed through the ASP.NET pipeline, including images, CSS and other resources. IIS by default only processes specific extensions (e.g., aspx) unless you tell it otherwise through configuration. Paths like '/content/images/yourimage.jpg' should work just fine...I suspect it's something amiss in your IIS configuration.

Another possibility which I've run into is any custom ISAPI filters you may have installed on the IIS server (e.g., ISAPI_rewrite). It's easy to set up rules in its configuration that lead to some very unexpected results.

Brandon Linton