Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET authentication forms not working with CSS?

So on my journey to become better at ASP.NET I've encountered a problem.

I'm working on a login. I added some style to it by adding a CSS file and after some time I made it look a lot better. Thereafter I added ASP authentication forms - which actually works great as well except that if you're not logged in the CSS is not used.

Once I've logged in and received a cookie I can go back to the login page and everything looks nice. But as long as I haven't "logged in" the page looks as if no CSS is used.

How can I fix this?

like image 575
Peter Rasmussen Avatar asked May 09 '26 22:05

Peter Rasmussen


2 Answers

You have to allow access to the CSS file:

<location path="~/stylesheets">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

Update to match the path to where you store your CSS.

like image 153
jonezy Avatar answered May 11 '26 12:05

jonezy


You need to exclude the CSS folder (and for that matter any other folders) from the authorization using location in the web.config.

<location path="CssFolder">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>
like image 35
amit_g Avatar answered May 11 '26 11:05

amit_g



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!