Web.config

The Web.config file contains the settings for your entire site.

Web.config Sections

Here the sections of Web.config will be noted


<Configuration> Section

This is actually the root of the config file, since it is actually an XML file

<ConfigSections> Section

No idea, lots of stuff in here, can't understand it at this point


<AppSettings> Section

Apparently this is where any custom settings you have will be set


<connectionStrings> Section

Here is where you put custom connection strings for your website. If your using a database, you'll probably use this site. An example connection string section is:

<connectionStrings>
    <add name="YourDBname" connectionString="Server=ServerName\InstanceName;Database=DBname;Trusted_Connection=True;"/>
</connectionStrings>

This example is for a SQL server running as an instance on a PC, YourDBName would be the name you want to refer to the DB as during the rest of the configuration process, ServerName is the name of the machine, InstanceName is… the name of the instance (Usually SQLExpress) and DBname is the actual name of the database on the SQLServer.
For more information on actually creating a connectionstring refer to http://www.connectionstrings.com

<system.web> Section

This section seems to have a lot going on, so we'll break it down.

<membership> Section

Membership is accomplished in system that uses "Providers"

Here is the syntax for adding a membership provider:
** NOTE: This is only the basic, quick and dirty, description of adding a provider **

<add
    name="Name"
    type="System.Web.Security.SqlMembershipProvider"
    connectionStringName="ConnectionStringName"
    applicationName="MyApplicationName"
    enablePasswordRetrieval="false"
    enablePasswordReset="true"
    requiresQuestionAndAnswer="true"
    requiresUniqueEmail="true"
    passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5"
    passwordAttemptWindow="10"
    minRequiredPasswordLength="1"
    minRequiredNonalphanumericCharacters="1"
    passwordStrengthRegularExpression=""
/>

Quick pointers:
  • Name, Type, connectionStringName and applicationName are the only fields that need to be set for each provider.
  • The rest of the fields listed are shown with defaults, unless you want to change these defaults you don't have include them.
  • If password format is set to "hashed", then password retrieval is not possible.

Full listing of everything you can do with the <add> element for the membership providers can be found here http://msdn.microsoft.com/en-us/library/whae3t94.aspx

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License