Solved

site.css not showing for login.aspx pages

Posted on 2010-08-24
9
907 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

839 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