Solved

site.css not showing for login.aspx pages

Posted on 2010-08-24
9
906 Views
Last Modified: 2012-05-10
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!!
0
Comment
Question by:genehayes
  • 5
  • 4
9 Comments
 
LVL 9

Expert Comment

by:wellhole
ID: 33511760
My guess is you have to allow anonymous access. Go to the website security settings and check the box.
0
 

Author Comment

by:genehayes
ID: 33512395
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.
0
 
LVL 9

Expert Comment

by:wellhole
ID: 33513497
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.
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 

Author Comment

by:genehayes
ID: 33513622
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!
0
 
LVL 9

Accepted Solution

by:
wellhole earned 500 total points
ID: 33513739
Do you see where you have

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

This means deny to anonymous users. You should try allowing your css file through then just as you allowed your login page.

<configuration>

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

   <location path = "Styles/Site.css">
      <system.web>
         <authorization>
            <allow users = "*" />
         </authorization>
      </system.web>
   </location>

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

</configuration>
0
 

Author Comment

by:genehayes
ID: 33513744
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?
0
 
LVL 9

Expert Comment

by:wellhole
ID: 33513774
I kinda just answered in the above post.
0
 

Author Comment

by:genehayes
ID: 33513861
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!!
0
 

Author Closing Comment

by:genehayes
ID: 33513876
Wellhole was also very quick with his responses and solutions.

Thanks!!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question