Below is My Web.config File Code I am using forms Authentication. I increased the Time out Time but still its not working with in 2 minutes My Application is Getting log out Automatically Again User had to sign in Again .
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DBCS" connectionString="Data Source=105.55.191.106;Initial Catalog=Trucks;User ID=Girish;Password=Girish123!@#" />
<add name="Truck_ManagementConnectionString" connectionString="Data Source=105.55.191.106;Initial Catalog=Trucks;User ID=Girish;Password=Girish123!@#;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="HomeMain.aspx" />
</files>
</defaultDocument>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
<system.web>
<sessionState timeout="60" />
<trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false" />
<customErrors mode="Off" />
<authentication mode="Forms">
<forms loginUrl="HomeMain.aspx" timeout="2880" defaultUrl="NewtrucksValidations.aspx">
<credentials passwordFormat="Clear">
<user name="Rajesh" password="Rajesh" />
<user name="Rajesh1" password="Rajesh1" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
<compilation debug="true" targetFramework="4.0" />
<pages buffer="true" enableEventValidation="false"></pages>
</system.web>
<system.net>
</system.net>
<appSettings>
<add key="microsoft.visualstudio.teamsystems.aspnetdevserver:/dxfsd" value="2772;True;4952;1;-8587766731921818473" />
<add key="microsoft.visualstudio.teamsystems.backupinfo" value="1;web.config.backup" />
<add key="token" value="AFcWxV21C7fd0v3bYYYRCpSSRl31AZ8FkzH5YTJtR8RVkxY6oiRdbOtN" />
<add key="paypalemail" value="akshithrajesh290-facilitator_api1.gmail.com" />
<!--Here i used sandbox site url only if you hosted in live change sandbox to live paypal URL-->
<add key="PayPalSubmitUrl" value="https://www.sandbox.paypal.com/cgi-bin/webscr" />
<add key="FailedURL" value="http://localhost:49666/PayPalIntegration/Failed.aspx" />
<!--Failed Page URL-->
<add key="SuccessURL" value="http://localhost:49666/Default.aspx" />
<!--Success Page URL-->
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"></assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Try setting the time when you creating the Authorisation cookie:
The Custom Identity Class Imports System.Data
The Custom Principal Class
My Global.asax methods
And Finally my Main Web.config
So with that in place i am able to control the timeout. Hope it helps you.
May be this is because of there is no
machinekey
specified. You can give it a try -Application pools can regularly be recycled. When recycling occurs, the ASP.NET will recreate a
MachineKey
, if there isn’t one specified inweb.config
. Machine key is used to generate Authentication ticket, so the newly recreated machinekey makes the current Authentication ticket invalid which causes users to logout. The solution to that is to add a<machinekey>
section in theweb.config
file.There are many tools for generating machinekey. you may try - http://www.developerfusion.com/tools/generatemachinekey/