Question

I've set up Forms Authentication on my ASP.NET MVC website, including setting up appropriate entries in the web.config.

Now every request to my site redirects to the Login page to authenticate the user.

Problem is, this happens even when my pages try to access the master stylesheet (in the Content folder), so they end up rendering without styles.

How can I override Forms Authentication so that my style sheet will render?

Was it helpful?

Solution

You need to exclude stylesheets from security in your web.config:

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

OTHER TIPS

if you are dealing with just one css file then you can add an exception on your web.config simiarly to what Chris KL wrote, but with the css file name instead:

 <location path="yourstyle.css">
        <system.web>
                <authorization>
                        <allow users="*"/>
                </authorization>        
</system.web>
</location>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top