Adv Web.Config Part 1

Submitted on: 1/3/2015 10:54:00 AM
By: Talha Ahmad, the Bill Gates (from psc cd)  
Level: Beginner
User Rating: By 5 Users
Compatibility: C#, VB.NET, ASP.NET, C++.NET
Views: 743
     This article is A-Z Web.Config for Forms Authentication. Good for Beginners.

Advanced Web.Config for Authentication

Well, After receiving so many emails asking about Web.Config, I have decided to write an article on "Web.Config for Forms Authentication".

First of all, there are three types of Authentication methods:

Windows Authentication
Forms Authentication
Passport Authentication

Since this article is about Web.Config, I am not going to explain what the above three do, how and why? So Let's start writing a Web.Config for Forms Authentication.

In my Web.Config file, I will find my Authentication node and change it to the following:

<authentication mode="Forms">
<forms name=".ASPXAUTH" protection="All" timeout="60" loginUrl="default.aspx" />

and then I will find the Authorization node and change it as follows:

<deny users="?" />

If the user wants to see a restricted access, it will take him to the default.aspx page. You can change it to Login.aspx or anything. Now, another import thing to know is that not all the pages are restricted in a web application, are they? So you want to tell the program to let the users view the pages which are not. So between your

</system.web> and </configuration>
in Web.Config file, add the following lines:

<location path="default.aspx">
<allow users="?" />

<location path="login.aspx">
<allow users="?" />

Now it will let the users view default.aspx and login.aspx. If you want to add more pages, copy and paste the above lines and change the name of the pages.

My next article will be on Forms Authentication and come with Samples. So please vote and motivate me to take some time out and write it for you. Visit my web site for articles, my online projects, E-PDF Creator, E-Chat, E-Messenger and E-Charts. A good site for newbies.

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

11/4/2017 11:49:04 AMDavid

This website
is now a web hosting site,
(If this comment was disrespectful, please report it.)


Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.