foreach (var item in ((ModelBase)Model).Stylesheets)
{ %>
<%=item.url %>
<link rel="stylesheet" type="text/css" href="<%= Url.Content(item.url)%>" />
<% }
I've got the code above running but whenever it outputs the 开发者_JAVA技巧link tag I get the following.
../../Content/Site.css<link rel="stylesheet" type="text/css" href="Views/Shared/%3C%25=%20Url.Content(item.url)%25%3E" />
I'm confused cause the item.url is outputting the correct value, and if I type the value in manually it's ok, but using item.url inside the url.content function causes the above to happen.
It's because the head tag was runat server.
What about just
foreach (var item in ((ModelBase)Model).Stylesheets)
{ %>
<link rel="stylesheet" type="text/css" href="<%=item.url %>" />
<% }
Depending on how you create the url property in your model, Url.Content is probably having trouble resolving it. Why not just reference it like this?
Edit: Sorry this doesn't really answer WHY your problem is happening, but instead just gives a work around if you can't figure it out.
精彩评论