PM's Blog

Pramod Mohanan's notes about ASP.NET, MVC, C#, SQL, jQuery, Bootstrap

Avoid Redirect to Login Page

When the following authorization is set in the config file at the site’s root, inside the system.web node, we notice that no object is rendered unless the user gets authenticated. This also includes images, style sheets, javascripts etc.

<authorization>
    <deny users="?" />
    <allow users="*" />
</authorization>

In cases like these, we see styling not being applied to the login page as well. Quite logical because the user hasn’t logged in yet. Right?

To allow ASP.NET to allow access to certain sections of the file system for example say the “styles” folder the following can be used. the example below allows access to “styles” folder in the “content” folder of the site.

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

The above goes directly as a child node of the configuration node in the web.config file

Leave a Reply

Your email address will not be published. Required fields are marked *

PM's Blog © 2018