Link to home
Start Free TrialLog in
Avatar of Relegence
RelegenceFlag for Israel

asked on

Login page looses styling when using forms authentication method

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?
Avatar of ChetOS82
ChetOS82
Flag of United States of America image

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.
Avatar of Relegence

ASKER


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

CJ S - How do I give access to the include files?
<location path="css">
 <system.web>
  <authorization>
   <allow users="?"/>
  </authorization>
 </system.web>
</location>
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?
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...
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.
ASKER CERTIFIED SOLUTION
Avatar of ChetOS82
ChetOS82
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial