Forms Authentication Using SQL - Part 1
page 3 of 4
by Jason N. Gaylord
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 21808/ 71

Section 2: Setting Up The Web.Config File
Now that the SQL side is setup, we can begin programming the ASP.Net pages. We will begin by configuring our web application. The configuration is stored in a file called web.config. A sample of the configuration is shown below:
Web.config
**************************************************

1:    <configuration>
2:    
3:    
4:       <!-- This section stores your SQL configuration as an appsetting called 
5:           conn. You can name this setting anything you would like. 
6:       -->
7:       <appSettings>
8:          <add key="conn" _ 
9:          value="server=localhost;database=MySite;uid=sa;pwd=password;" />
10:      </appSettings>
11:   
12:   
13:      <!-- This section sets the authentication mode to forms authentication 
14:          and routes all traffic to the specified page. It also specifies a 
15:          timeout. The authorization section below denies all users not 
16:          authenticated. For testing purposes, custom errors was turned off. 
17:          The section below allows pages to be trace enabled for debugging 
18:      -->
19:      <system.web>
20:   
21:         <authentication mode="Forms">
22:            <forms name="MyFormsAuthentication" loginUrl="login.aspx" _ 
23:            protection="All" timeout="720" />
24:         </authentication>
25:   
26:         <authorization>
27:            <deny users="?" />
28:         </authorization>
29:   
30:         <customErrors mode="Off" />
31:   
32:         <trace enabled="true" requestLimit="0" pageOutput="true" />
33:   
34:       </system.web>
35:   
36:   
37:   </configuration>

This will setup the basic web.config file that we will need.

View Entire Article

User Comments

Title: c# code   
Name: raj
Date: 2011-05-25 7:51:10 AM
Comment:
Hi I want the code in C#, can u please send it?
Title: login authentication in asp.net   
Name: khyati
Date: 2009-07-13 1:09:45 AM
Comment:
very good!
Title: Good stuff   
Name: jes
Date: 2007-04-16 3:31:45 AM
Comment:
I got an error in this line
intResult = myCmd.Parameters( "RETURN_VALUE" ).Value
when i converted the code to c#.error is
intResult = myCmd.Parameters( "RETURN_VALUE" ).Value

how do i solve this
Title: Nice done but...   
Name: Edgar
Date: 2006-09-12 4:25:17 PM
Comment:
I just have a little question. What if i want to know the username of the user in other wepages???.
Title: good   
Name: ANTONY LEO EDEL
Date: 2006-03-27 5:40:52 AM
Comment:
easy to understand . lot of thanks
Title: Woooow   
Name: Eryk
Date: 2006-02-02 4:50:17 PM
Comment:
Very Very Good.
Title: very good   
Name: Tuncay
Date: 2006-01-14 2:20:40 AM
Comment:
thanks, this tutorial is very good.
Title: RE:   
Name: Bryan
Date: 2005-11-15 3:46:14 PM
Comment:
Convert sqlCommand2.Parameters["RETURN_VALUE"].Value to a integer
Title: a question!   
Name: mohammad
Date: 2005-11-12 10:15:36 AM
Comment:
hello ,thanx for this grat code ,but i have a prob!!
i have converted this code to C# and every thing is fine exept this statment
ntResult = sqlCommand2.Parameters["RETURN_VALUE"].Value;
it say can nit implicit convert from in to object ,
so can u help me in doning it in c#?
Title: excellent   
Name: jh
Date: 2005-10-03 5:21:58 PM
Comment:
very nice work - thanks much!
Title: need an import though   
Name: jh
Date: 2005-10-03 5:14:52 PM
Comment:
it neededs this at the top of the page though:

Imports System.Web.Security
Title: Perfect   
Name: Jacques
Date: 2005-07-29 4:49:45 AM
Comment:
Thank you. Just what i needed.
Title: WellDone   
Name: Man
Date: 2005-06-16 10:29:39 PM
Comment:
This was very well done and cover a whole lit of stuff that I actually was after!

Thanks!
Title: Gant   
Name: Gant Man
Date: 2005-05-28 11:30:31 PM
Comment:
Thanks

Just what I was after
Title: Good   
Name: Majun
Date: 2005-02-10 2:56:41 AM
Comment:
Very Good.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-29 8:05:15 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search