Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ASP.NET Authorization Yet Permit Access to .css Files?

<authentication mode="Forms">
      <forms loginUrl="Login.aspx"/>
</authentication>
<authorization>
      <deny users="?"/>
</authorization>

I am using forms authentication, and when i place the arguments cited above, the css formatting I have done for the whole document is not being implemented, it's vanishing. what should i be doing so that the CSS remains intact.

like image 305
Chaitanya Avatar asked Jan 27 '10 02:01

Chaitanya


2 Answers

I assume that your login form has an external CSS file, and that you're using Cassini or IIS 7 integrated mode.

Your <deny users="?"/> is preventing anonymous users from seeing the login form's CSS files.

You need to use the <location> element to allow anonymous users to see the CSS files, like this:

<location path="CSS">
    <system.web>
        <authorization>
            <allow users="?"/>
        </authorization>
    </system.web>
</location>
like image 145
SLaks Avatar answered Oct 20 '22 11:10

SLaks


Use the location element to allow access to your css:

<configuration>
   <location path="style.css">
      <system.web>
         <authorization>
            <allow users="?"/>
         </authorization>
      </system.web>
   </location>
</configuration>
like image 23
sestocker Avatar answered Oct 20 '22 12:10

sestocker