views:

411

answers:

2

I changed the MembershipProvider in my ASP.net MVC website, and now the stylesheet for the login page isn't referenced correctly. Below is a copy of the forms tag in my web.config if that could be the reason. It looks identical though to the one generated by a new project with the exception of the name and timeout attribute.

<authentication mode="Forms">
      <forms loginUrl="~/Account/Login" name=".ADAuthCookie" timeout="10" />
</authentication>

When I visit the page now, the link tag for the CSS looks like this:

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

When it should look like this:

<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
+1  A: 

I haven't used ASP.NET MVC yet myself, but you could try using ResolveClientUrl when writing out the href for your CSS:

<link href="<%= ResolveClientUrl("../../content/Site.css") %> rel="stylesheet" type="text/css" />
Ian Oxley
I didn't realize this thing started to exist in .NET 2.0. Very useful! Thanks.
Brian Kim
A: 

Thanks Ian Oxley. The problem wasn't solved with the ResolveClientUrl though.

It had to deal with the web.config file. I had code that looked like this:

<authorization>
  <deny users="?" />
  <allow users="*" />
</authorization>

I added a location element below the main one and said that anybody could view that content, and it works now. It turns out that files like the CSS file were not viewable until authorized before. That is now fixed.

This is what I added:

<location path="Content">
   <system.web>
      <authorization>
         <allow users="*" />
      </authorization>
   </system.web>
</location>
Jared