Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

site.css not showing for login.aspx pages

Posted on 2010-08-24
9
Medium Priority
?
923 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

604 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