title: Session timed Out in MVC 4
body: <p>I searched many sites and including <strong>Stackoverflow</strong>, about using session timed out in MVC, but all sites and code shows only part of the code which is used in WebConfig, but it doesn't shows where in webconfig needed to be filled</p>
  
  <p>I am developed a Application and now I want to add session timed out after 5 mins if the application is idle, many have stated to use Client Side and Server side too, I am little bit confused where to use it. 
  and I have found from stackoverflow following code which can be used in WebConfig </p>
  
  <pre><code> &lt;system.web&gt;
    &lt;sessionState timeout="30"&gt;&lt;/sessionState&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>my question is which webconfig and where exactly that to be added ?? <strong>because in MVC I have 2 webconfig file</strong> one in View and another in main project, I have tried applying in both webconfig, just next to the "configuration" like this</p>
  
  <pre><code> &lt;configuration&gt; 
       &lt;system.web&gt;
    &lt;sessionState timeout="30"&gt;&lt;/sessionState&gt;
  &lt;/system.web&gt;
    &lt;/configuration&gt;
  </code></pre>
  
  <p>and it generates error message, so please let me know how can I use Session timed out for this application</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>Thanks for all your replies, I have applied all the code below, and have attached screen shot of error message please check it and let me know what I am doing wrong
  1) if I use the below code from i.e.</p>
  
  <pre><code>  &lt;system.web&gt;
    &lt;sessionState mode="InProc" cookieless="false" timeout="30"&gt;&lt;/sessionState&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>under  in main web config then gets error message as below pic
  <img src="https://i.stack.imgur.com/aQBP9.jpg" alt="on main webconfig"></p>
  
  <p>2) if i used same code on webconfig under views, i get this error pic
  <img src="https://i.stack.imgur.com/DbCza.jpg" alt="on view webconfig"></p>
  
  <p>along with that I am attaching a image file of both of my webconfig files</p>
  
  <p>-><img src="https://i.stack.imgur.com/eqkWm.jpg" alt="in View WebConfig"></p>
  
  <p>-><img src="https://i.stack.imgur.com/AkKuy.jpg" alt="in main Webconfig"></p>
  
  <p>hope I have shared more info, ask me if I am missing out something</p>
  
  <p><strong>UPDATE2</strong></p>
  
  <p><strong>main webconfig</strong></p>
  
  <pre><code>&lt;configuration&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
  &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/&gt;
  &lt;sectionGroup name="businessObjects"&gt;
    &lt;sectionGroup name="crystalReports"&gt;
      &lt;section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler, CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null" /&gt;
      &lt;section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" /&gt;
    &lt;/sectionGroup&gt;
  &lt;/sectionGroup&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;businessObjects&gt;
    &lt;crystalReports&gt;
      &lt;rptBuildProvider&gt;
        &lt;add embedRptInResource="true" /&gt;
      &lt;/rptBuildProvider&gt;
      &lt;crystalReportViewer&gt;
        &lt;add key="ResourceUri" value="../crystalreportviewers13" /&gt;
      &lt;/crystalReportViewer&gt;
    &lt;/crystalReports&gt;
  &lt;/businessObjects&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;add name="webPortalConnectionString" connectionString="Data Source=mysys-021\SQLEXPRESS;Initial Catalog=LIS_MHL_LIVE;User ID=sa;Password=cspl#" providerName="System.Data.SqlClient"/&gt;
  &lt;add name="LISConnectionString" connectionString="User ID=sa;Password=cspl#; Data Source=mysys-021\SQLEXPRESS;INITIAL CATALOG=LIS_MHL_LIVE;Persist Security Info=True" providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>
    
        
        
        
        
        
        
        
        
    
    <br>
      </p>
  
  <pre><code>&lt;compilation debug="true" targetFramework="4.5"&gt;
    &lt;assemblies&gt;
      &lt;add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/&gt;
      &lt;add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/&gt;
      &lt;add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/&gt;
      &lt;add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/&gt;
      &lt;add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/&gt;
      &lt;add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/&gt;
      &lt;add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/&gt;
    &lt;add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/&gt;&lt;/assemblies&gt;
  &lt;/compilation&gt;
  &lt;httpRuntime targetFramework="4.5"/&gt;
  &lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="~/Account/Login" timeout="2880"/&gt;
  &lt;/authentication&gt;
  &lt;pages&gt;
    &lt;namespaces&gt;
      &lt;add namespace="System.Web.Helpers"/&gt;
      &lt;add namespace="System.Web.Mvc"/&gt;
      &lt;add namespace="Kendo.Mvc.UI"/&gt;
      &lt;add namespace="System.Web.Mvc.Ajax"/&gt;
      &lt;add namespace="System.Web.Mvc.Html"/&gt;
      &lt;add namespace="System.Web.Optimization"/&gt;
      &lt;add namespace="System.Web.Routing"/&gt;
      &lt;add namespace="System.Web.WebPages"/&gt;
    &lt;/namespaces&gt;
  &lt;/pages&gt;
  </code></pre>
  
  <p>
    
      
      
        
        
        
        
        
        
      
    
    
      
        
          
          
        
        
          
          
        
        
          
          
        
      
    
    
      
    
  </p>