Reputation: 357
I have a strange problem with IIS on XP.
I have a ASP.MVC web application with a virtual directory pointing to it.
The application works OK, I see the generated html pages. The problem is that I get 404 errors for all the static content files (css,js and image files).
The really strange thing is that if I create an application directly on the directory the static content is served, but I can't get the static content from a virtual directory pointing to the same directory!.
BTW, the static content is served OK from the virtual directory created by VS2010 for the application.
I can't find any differences in the configuration in the IIS between the virtual directory created by VS2010 (that works) and the one that does not work.
I anybody got any ideas, I would be VERY gratefull...
Thanks,
Nadav
Upvotes: 1
Views: 1222
Reputation: 1038840
I suspect that you have hardcoded the url to those static files like that:
<script type="text/javascript" src="/scripts/foo.js"></script>
instead of using Url helpers:
<script type="text/javascript" src="@Url.Content("~/scripts/foo.js")"></script>
which would of course account for the presence of the virtual directory and generate the proper url to this static file when the application is hosted inside a virtual directory:
<script type="text/javascript" src="/myappname/scripts/foo.js"></script>
Upvotes: 1