Showing posts with label Web.config file. Show all posts
Showing posts with label Web.config file. Show all posts

Wednesday, 24 September 2014

What is the web.config file?



The Web.config file is the configuration file for the ASP.Net web application. There is one web.config file for one ASP.Net application that configures the specific application. The Web.config file is written in XML with specific tags having specific meanings. It includes data that includes connections, Session States, Error Handling, Security and so on.

For example:

< configuration >
< appSettings >
< add key="ConnectionString" value="server=localhost;uid=sa;pwd=;database=TestDB" / >
< /appSettings >
< /configuration >

What is the use of Web.Config file in asp.net?

It is the XML Configuration file used in asp.net. The web.config file contains information that control module loading, security configuration, session state configuration, and application language and compilation settings. Web.config files can also contain application specific items such as database connection strings. 


Tuesday, 22 July 2014

How to set custom session timeout in asp.net?

By default our websites session timeout is 20 minutes after that session will gets expire suppose if we want to set our custom timeout in our applications.

We can set timeout in different ways:
  • From web.config
  • From global.asax 
  • From IIS

In Web.config file, we can set session timeout like as shown below 

<configuration>
<system.web>
 <sessionState mode="InProc" timeout="60">
 </sessionState>
 </system.web>
</configuration>

In Global.asax file, we can set session timeout in Session_Start event like this

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Session.Timeout = 15;
}

In IIS setting, we can also set default session timeout.

             1) Open IIS start-->run type-->inetmgr and press enter.

             2) Right Click on "Default Web Site" go to properties

             3) Select Asp.Net tab, click on "Edit Configuration" Button 

             4) Select "State Management tab" in new popup window

     In case if you are using IIS7
  • Select Default Web Site >> Click on Session State