views:

1097

answers:

3

I have an Asp.net MVC2 web application. I built the application using VS2008 and tested on internal server, everything was perfect but when i deployed that web application on a local IIS the paths to images in web pages and in css file was not correct.

I need to change those paths for working with internal server and local server. How can i overcome this problem???

thanks

+3  A: 

To avoid this sort of problems you should always use the built-in helpers to generate URLs. For example:

<script type="text/javascript" src="<%= Url.Content("~/scripts/somescript.js") %>"></script>

and for links

<%= Html.ActionLink("Link text", "action", "controller") %>
Darin Dimitrov
+1  A: 

Try something like this:

<link href="<%= Url.Content("~/Content/Site.css") %>" rel="stylesheet" type="text/css" />

The tilde ("~") represents the root and the Url.Content does the appropriate magic to get you a nice tidy reference.

Murph
A: 

Have you tried opening the CSS and Images directly (i.e. not via being called on a page)? Does that work?

How do you link to them on your internal server, if the relative paths don't equate the same, you'll have the problem you describe. An example about how you might fix this is to use Url.Content().

e.g. Instead of using:

<link rel="Stylesheet" href="/Styles/Reset.css" />

You would use:

<link rel="Stylesheet" href="<%=Url.Content("~/Styles/Reset.css")%>" />

This would work out the URL depending upon where the application lives on that box - not relative for the web root.

Amadiere