//
you're reading...
ASP.NET, IT-Center, Web Based

Write and Read ASP.NET Web.Config

All setting website can be define in web.config file. The first we must understand regulation how to write and read the config, these is standart format web.config :

<configuration>
   <configSections>
      <sectionGroup name="system.net">
         <section name="authenticationModules"
            type="System.Net.Configuration.NetAuthenticationModuleHandler,
            System, Version=1.0.3300.0, Culture=neutral,
            PublicKeyToken=b77a5c561934e089"/>                              
         <section name="webRequestModules"
            type="System.Net.Configuration.WebRequestModuleHandler,
            System, Version=1.0.3300.0, Culture=neutral,
            PublicKeyToken=b77a5c561934e089"/>
       </sectionGroup>
       <sectionGroup name="system.web">
          <section name="authorization"
             type="System.Web.Configuration.AuthorizationConfigHandler,
             System.Web, Version=1.0.3300.0, Culture=neutral,
             PublicKeyToken=b03f5f7f11d50a3a"/>           
          <section name="sessionState"
             type="System.Web.SessionState.SessionStateSectionHandler,
             System.Web, Version=1.0.3300.0, Culture=neutral,
             PublicKeyToken=b03f5f7f11d50a3a"
             allowDefinition="MachineToApplication"/>       
       </sectionGroup>
    </configSections>
   <system.net>
      <! — Net Class Settings would go here. -->
   </system.net>
   <system.web>
        <authorization>
            <allow users="*"/> <!-- Allow all users -->
            <!-- Allow or deny specific users.
            allow users="[comma separated list of users]"
                  roles="[comma separated list of roles]"/>
            <deny users="[comma separated list of users]"
                  roles="[comma separated list of roles]"/>
            -->
        </authorization>
        <sessionState
            sqlConnectionString="data source=localhost;
               Integrated Security=SSPI;
               Initial Catalog=northwind"
            cookieless="false"
            timeout="10"/>
   </system.web>
</configuration>

APPSETTING 
these sample key and value appSetting in webconfig :

<configuration>
  <appSettings>
     <add key="host" value="(local)"/>  <!-- database host -->
    <add key="user" value="sa"/>      <!-- sa / windows -->
    <add key="pwd" value="nGXi18B4Ka0="/>  
    <add key="dbname" value="thedatabase"/>   <!-- database name -->
    <add key="MinPoolSize" value="10"/> <!-- min 10 -->
    <add key="MaxPoolSize" value="200"/>  <!-- max 200 -->
    <add key="pooling" value="false"/>   <!-- default true -->
 </appSettings>
 

How to read the config in ASP.NET:

    Public p_path As String = ConfigurationSettings.AppSettings("path")
    Public p_host As String = ConfigurationSettings.AppSettings("host")
    Public p_user As String = ConfigurationSettings.AppSettings("user")
    Public p_password As String = ConfigurationSettings.AppSettings("pwd")
    Public p_dbname As String = ConfigurationSettings.AppSettings("dbname")

    Public p_MinPoolSize As String = ConfigurationSettings.AppSettings("MinPoolSize")
    Public p_MaxPoolSize As String = ConfigurationSettings.AppSettings("MaxPoolSize")
    Public p_pooling As String = ConfigurationSettings.AppSettings("pooling")

    Public p_connectionString As String = ConfigurationSettings.AppSettings("connectionString")

 WRITE & READ SESSION SETTING

</system.web>
            <sessionState timeout="15"></sessionState>
       </system.web>

in ASP.NET you can read setting with :

Session.Timeout

GLOBAL SETTING (LANG & REGIONAL SETTING)
 

<globalization
           fileEncoding="utf-8"
           requestEncoding="utf-8"
           responseEncoding="utf-8"
           culture="en-US"
           uiCulture="de-DE"
        />

UPLOAD SIZE & MAX EXECUTE TIME IIS
web.config setting :

<httpRuntime
        executionTimeout="1200"
        maxRequestLength="209715"
      />

About berbagisolusi

Berbagi merupakan sebuah bentuk simbol keikhlasan untuk membantu dan menolong, sedangkan solusi adalah cara menyelesaikan masalah. Setiap manusia pasti mengalami masalah, tetapi kita tidak perlu mengalami masalah yang sama jika orang lain pernah mengalami dan kita tahu hal tersebut.

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 9 other followers

December 2011
M T W T F S S
« Nov   Jan »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Web Statistic

Blog Stats

  • 149,580 hits
%d bloggers like this: