ASP.NET MVC 2 relative paths for scripts and styles
Posted
by Tomaszewski
on Stack Overflow
See other posts from Stack Overflow
or by Tomaszewski
Published on 2010-05-04T22:21:34Z
Indexed on
2010/05/04
22:28 UTC
Read the original article
Hit count: 380
Hi, having this really silly problem in ASP.NET MVC 2 with .NET 4.
I need to test other pages using localhost, but sometimes I need to show the page to some else on another computer and so need to path out to my machine. In doing so, I need to use relative paths for my and tags. When I test through VS, I use relative path:
<script src="../../Scripts/somejavascript.js"></script>
<link href="../../Styles/somestyle.css" />
However, when I publish to local IIS, I'm having all sorts of problems beacuse the Scripts and Styles folder are at the same directory level, but it seems like I have to path out differently. For example, in the scenario above the styles will be picked up but the JavaScript won't be.
Any ideas on how best to path out, relatively using MVC 2?
© Stack Overflow or respective owner