I’m writing my first MVC2 app. I’ve got my master page working beautifully, and when I run it locally it functions exactly like I want it to.
My problem is that I’m deploying it on a server that has a whole bunch of Applications. ResolveUrl seems to be misbehaving. I get the correct path, but for whatever reason something is inserting an extra quote, or dropping the quotes I have.
Here’s my <link>:
<link href='<%= ResolveUrl("~/Content/Site.css") %>' rel="stylesheet" type="text/css"/>
What comes out (client side, after ASP.NET is through with it):
<link href=/vcdemo/PhotoManager/Content/Site.css" rel="stylesheet" type="text/css" />
Obviously it’s not what I want. When I correct the quotes in Firebug the site displays correctly.
Any ideas?
You should be using the
Url.Contenthelper:Also as it seems that you are using the WebForms view engine make sure you have removed any
runat="server"attributes that might be present on the<head>tag.ResolveUrlandrunat="server"are legacy stuff and should not be used in an ASP.NET MVC application.