I'm getting headaches from trying to host MVC 2 on XP's IIS! (This is on VS 2008, but probably applies to VS 2010 as well.)
After much struggling I eventually found a way to display my MVC 2 site from IIS 5.1, but the problem is that there is no styling! Any ideas on how I should fix this?
The problem is probably the path location. Following the suggestions from the link above, if I change the relative path of my CSS link from <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
to <link href="%3C%=Url.Content%28" ~="" content="" site.css="" )="" %>="" rel="stylesheet" type="text/css" />
then it does not do any conversions. When I change it to <link href="<%=Url.Content(" ~="" content="" site.css="" )="" %>="" rel="stylesheet" type="text/css" />
then I get the error "Newline in constant."
EDIT: The normal <link href="<%= Url.Content("~/Content/Site.css")%>" rel="stylesheet" type="text/css" />
translates to <link href="/Mvc2.VS2008/Content/Site.css" rel="stylesheet" type="text/css" />
(where Mvc2.VS2008
is my website root), but Content/Site.css
is not found when hosted this way.
I'm not exactly sure what the problem was, but the value returned by Url.Content()
was not recognized by the IIS Server (you could not retrieve it from the browser). In fact, I am not supposed to need it for simple links anyway.
Steps to fix:
cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
)Metaacl.vbs "IIS://localhost/W3SVC"
Metaacl.vbs "IIS://localhost/W3SVC" Everyone R
<authentication mode="Windows" />
in web.config
) requires you to enable Integrated Windows Authentication in the IIS Directory Security.<authorization><deny users="?"/></authorization>
in web.config
, or uncheck "anonymous access" in the IIS Directory Security)Now everything should be just peachy (it worked on my PC). There should no longer be any need for Url.Content()
, and styling should just work.