views:

262

answers:

1

I am very confused because I am using iis7 integrated and so I should not need default.aspx in my project. However, after upgrading to rc at run time there is no style anywhere in my site. Here is my link to the style sheet that lives along side the master page. At design time, vs is able to pick up the style sheet so I have no idea whatt might be going wrong.

<link href="Stylesheet.css" rel="stylesheet" type="text/css" />

At run time this evaluates to

<link href="Views/Shared/Stylesheet.css" rel="stylesheet" type="text/css" />

Which seem like it should be fine.

+3  A: 

I would move your style to the Content/Styles directory; this is where they would normally live. I suspect that the routing engine blocks direct access to any files in the View directory as a precaution (so people can't see your view code). You'll need to change your link to:

 <link href="<%= Url.Content( "~/Content/Styles/Stylesheet.css" )"
       rel="stylesheet"
       type="text/css" />

Or if you want to hard-code the path to the root:

<link href="/Content/Styles/Stylesheet.css"
      rel="stylesheet"
      type="text/css" />

I do something similar to the former but with an extension method that appends the current date as a query parameter (?d=YYYYMMDD) format to the end of the url so that cached CSS files get updated regularly as I make changes. If you do this, though, you'll need to include the latter wrapped in an if (false) directive to make sure you don't lose intellisense.

<% if (false) { %>
  <link href="/Content/Styles/Stylesheet.css"
        rel="stylesheet"
        type="text/css" />
<% } %>
tvanfosson