Wednesday, March 30, 2011

CSS is not applied on login page in ASP.NET

Hi All,
If you are working with asp.net and you tried to apply css classes on your web application which is linked in your master page. You might face a problem that the css classes doesn't show on your login page but it shows properly after you logged in to your application by clicking on sign out link.

The problem is a security permission problem, since by default the asp.net application has a rule that doesn't allow all users to access folder within your project, to fix this problem, you want to allow all users to access your css file in your folder, So let's say you have css files in your Styles folder in your web project; You need to allow all users in web.config to access these files, so this fixes this problem in login.aspx page.

Add the following in your web.config to fix this issue:

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


After applying this, try to run your application and you will see the css classes are applied in your login page before signing in or after signing out.

Hope this helps.

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

No comments: