We help IT Professionals succeed at work.

Login page looses styling when using forms authentication method

Relegence
Relegence asked
on
849 Views
Last Modified: 2013-11-07
Hello,
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?
Comment
Watch Question

Commented:
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).

Commented:
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.

Author

Commented:

Here is the relevant code;

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

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

Author

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

Commented:
<location path="css">
 <system.web>
  <authorization>
   <allow users="?"/>
  </authorization>
 </system.web>
</location>

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

Author

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

Author

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

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

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

Author

Commented:
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

Commented:
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

Author

Commented:
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.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

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.

OR

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.