Link to home
Start Free TrialLog in
Avatar of genehayes
genehayes

asked on

site.css not showing for login.aspx pages

I'm not sure what I did, but I'm pretty sure it was my fault...

I have an ASP.NET 4.0 project created with VS 10 VB.NET.  I created the project as ASP.NET (not Empty) and it was nice enough to create all my login pages for me.

All went well until I broke something when adding authentication/authorization to the site.

Now when someone is redirected to the login page, none of the site.css settings are applied.  Once they have successfully logged in, .css works just fine.

When I look at the code behind using the "Developers Tools" in Explorer 8.0, I see that the file being referenced (Styles\Site.css) is being called before Authentication with "Unknown" in the content and after Authentication with the full .css loaded.

This seems to be an Auth problem, but I can't figure out how to fix it.  I've tried changing security settings on the site.css file.  I've tried adding the .css file to the "location" portion of web.config.

I'm pretty sure it is something else I've done earlier, because when I try to retrace my steps with a new Test site created the same way, I don't have the same problem when I add Auth to that new site.  I just can't figure out what the difference is...  Grrrrr!

I am not very familiar with the IIS, .css and/or Auth set up, so any advice would be welcome at this point.

Thanks!!
Avatar of wellhole
wellhole

My guess is you have to allow anonymous access. Go to the website security settings and check the box.
Avatar of genehayes

ASKER

I did mess with anonymous access a bit both in the site and the actual directories where the info is stored, but that hasn't worked so far.

I tried again just in case, but still no dice.  It seems to have everything to do with Authentication and/or Authorization.

As if the user doesn't have permission to use the site.css file until they are authorized, which is not how the test site works.

If it helps, this is a problem both during debug sessions and when publishing to the live site itself.

Again, the Test site I created doesn't have this issue.
Check out your web.config file and look for the authorization tags. It should be helpful to know who are allowed to what pages. Perhaps you're blocking the css directory from unauthorized access.
Here is what was added to use "Forms" authentication in the root's web.config file:
    <authentication mode="Forms">
      <forms  name=".ASPXAUTH"
              loginUrl="~/Account/Login.aspx" timeout="2880"
               path="/"
               slidingExpiration="true"
               cookieless="UseDeviceProfile"/>

    </authentication>
    <authorization>
      <deny users="?"/>
    </authorization>

In the /Accounts web.config file there is also this:

<configuration>

  <location path="Login.aspx">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

  <system.web>
    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>

</configuration>

Is there something I need to add to the default directories web.config file to allow access to the /Styles/Site.css file?  I don't see anything like that in the test file that works just fine, but that probably doesn't mean anything.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of wellhole
wellhole

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, I kind of fixed it...

I had to add a web.config file to each directory where the \Styles\Site.css file and the Images\image.jpg file is located and setting the "Location" path to the individual files for "Allow Users = *".

I'm not sure what I did that would require it or if there is an easier way from the root's web.config file to do the same thing.

Ideas?
I kinda just answered in the above post.
Your answer was better!

I thought I had tried that but got an error saying I had illegal characters.  I probably used a \ when I should have used a /.

I've now fixed my site so that it only has the one web.config file so it won't be confusing later.

Thanks for all your help on this!!
Wellhole was also very quick with his responses and solutions.

Thanks!!