We help IT Professionals succeed at work.

Login page looses styling when using forms authentication method

Relegence asked
Last Modified: 2013-11-07
I am writing a c# asp.net 2.0 application and using the forms authentication method for authentication.
A strange thing is happening - The authentication tag in web.config redirects to Login.aspx page.
This works fine, but when the Login page appears, it appears without the style, even though it is attached to a stylesheet.
when I open the Login page independently, it does have all the styling.
Why does it happen?
Watch Question

When you say, "though it is attached to a stylesheet", are you sure it is attached.  Have you checked the HTML code to verify that?
Can you paste the code that loads the stylesheet?  And maybe a description of the paths of each file (i.e. stylesheet.css, login.aspx, etc).

You probably will only see this while debugging your application - e.g. when it runs within it's own webserver. This is because all file-types are handled by the asp.net proces and thus passes the settings of the web.config.

If you want it to work you would need to give everybody access to the include files, same way as you would give access (or deny access) to any of your other pages / folders.



Here is the relevant code;

In the web.config file;
<authentication mode="Forms">
        <forms name="AOLTickerToolCookie" loginUrl="DoLogin.aspx" path="/" protection="All" timeout="120">

In DoLogin.aspx page:
<link href="Style.css" rel="Stylesheet" type="text/css" />

I've checked the source and it seems that the Login file is attached to the stylesheet correctly


CJ S - How do I give access to the include files?

<location path="css">
   <allow users="?"/>

Put that outside the <system.web> directive - not inside.


thanks - I'll try and let you know if it worked


I  am afraid it didn't help. I put it under <configuration>, is that ok?

Strange - maybe a clientside caching issue then?
Top Expert 2007

does it work if you put the styles in the login page between the head tags?


Yes, It works if I pit the style between the head tags.
But, another problem, related to the previous one, still happens - I have an imageButton which isn't displayed.
Something is wrong with the paths...
Top Expert 2007

all paths in the CSS are relative to where the CSS is.

in the head tags it would be relative to to where the page is.

in the css folder, the path to images in an 'images' folder at the same level as the 'css' folder would be -> ../images/myimage.gif


I know that paths are relative to where the css is.
The strange thing is that I've done this so many times before (this is a basic) and here it just doesn't work.
Since I'm calling the Login page using "authentication" in my web.config file, I think it is related to this somehow.
This one is on us!
(Get your first solution completely free - no credit card required)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.