Friday, August 8, 2008

Exclude pages from authentication in ASP.Net

Hi...

I have implemented Asp.Net Membership Management in my current application. There are some pages which is going to be displayed on the clients website for anonymous users. So for these pages I have made sure that i am not using session variables which i used in other pages. I have excluded the page from Master page hoping that it would not require authentication. But that will not work. Actually we need to specify the respective page or folder in web.config saying that the authorization is anonymous. Following are the nodes to be placed under Configuration node in Web.Config file.

<location path="Your-File.aspx">
<system.web>
<authorization>
<allow users="*">
</allow>
</authorization>
</system.web>
</location>

Or

<location path="Your-Folder">
<system.web>
<authorization>
<allow users="*">
</allow>
</authorization>
</system.web>
</location>

Or

<location path="Your-Folder/Your-File.aspx">
<system.web>
<authorization>
<allow users="*">
</allow>
</authorization>
</system.web>
</location>

[Updated] Note: Please remember to add your Images folder, Styles.css and other common files & folders which is used inside the nodes as shown above.

Now it is a stand alone page & it works fine...

Regards
Fauzi ~ Olympics fever has started :)

No comments: