Solved

site.css not showing for login.aspx pages

Posted on 2010-08-24
9
904 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now