Timeout and force logout?
-
Dienstag, 5. Juni 2012 10:33
When my app inactive in a long time. All other screens can't connect database and display red x. An error box show error about time out.
How can i force user logout and re-login when my app in timeout state?
Thank you.
- Verschoben Steve HoagMicrosoft Employee, Moderator Mittwoch, 15. August 2012 04:46 forum retired (From:LightSwitch in Visual Studio 2012 RC)
Alle Antworten
-
Dienstag, 3. Juli 2012 19:53
I have the same trouble. Changing web.config or other suggested solutions unfortunately did not work for me.
Could someone please help us with this? Thanks!
Domagoj
-
Mittwoch, 4. Juli 2012 01:59
Hi Domago,
Look for the web.config file in Server project. add the timeout in the following tags:
<connectionStrings> <add name="_IntrinsicData" connectionString="Data Source=|SqlExpressInstanceName|;AttachDbFilename=|ApplicationDatabasePath|;Integrated Security=True;Connect Timeout=120;User Instance=True;MultipleActiveResultSets=True" /> </connectionStrings> <authentication mode="Forms"> <forms name="Auditoria" timeout="120" /> </authentication> <sessionState timeout="120" />
I put 120 which is 2 hours
-
Mittwoch, 4. Juli 2012 08:36
I tried that earlier... It is just that I am a beginner in programming so often I do something wrong :)
I tried putting your code in web.config that is on my computer in folder VS2010\Projects\...\ServerGenerated\ and after that deployed the app. - no success
When I manualy try to change web.config that is on the 3rd party IIS, then I get each kind of errors in opening application. :)
In my case at 3rd party IIS I have 2 web.config files. The one in root folder, for the main page:
<?xml version="1.0" encoding="UTF-8"?>
< configuration>
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="false" />
<anonymousAuthentication enabled="true" userName="" />
<basicAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
<location path="MyApp2012">
</location>
<system.web>
<authentication mode="Windows" />
</system.web>
< /configuration>(This one does not change when i deploy LS app.)
And there is another one in folder with LS application (too long to make sense pasting here). Deploying affects this one, it received changes with conn.strings, authentication mode and timeout ="120".
Maybe I need to change the first mentioned web.config in root folder? (when I tried, I failed miserably...lots of errors)
Similar to your suggestion is LightSwitch timeouts and SessionState service (also no effect with my app)
I think this one would work, but it is in written in C, and I am struggling even with VB...
Lightswitch Inactivity Timeout
Could someone translate solution in C from link above to Visual Basic?
My apologies for being ignorant about these topics! Thanks for trying to help us!!!
Best regards
Domagoj
- Bearbeitet DomagojBulat Mittwoch, 4. Juli 2012 08:37
- Bearbeitet DomagojBulat Mittwoch, 4. Juli 2012 08:53
- Bearbeitet DomagojBulat Mittwoch, 4. Juli 2012 08:54
- Bearbeitet Yann DuranModerator Freitag, 8. Februar 2013 00:08 Fixed link text
-
Mittwoch, 4. Juli 2012 11:41
1º- In the Client project in folder UserCode find the Application.vb and add this code...
Namespace LightSwitchApplication Public Class Application Private Sub Application_Initialize() Me.Details.ClientTimeout = 1000 End Sub End Class End Namespace
2º Web.config
- if your application is in v1 then go here
ServerGenerated project
- if your application is in v2 then go here
Server project
- if your application is in v1 and upgrated to v2 then go here
ServerGenerated project and Server project
this is my configuration file. compare it with your...
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <appSettings> <add key="UserCodeAssemblies" value="Application.Common.dll;Application.Server.dll;" /> <add key="ExtensionAssemblies" value="ExcelImporter.Common.dll;ExcelImporter.Server.dll;ManyToManyControls.Common.dll;ManyToManyControls.Server.dll;PixataCustomControls.Common.dll;PixataCustomControls.Server.dll;Microsoft.LightSwitch.Extensions.Server.dll" /> <!-- A value of true will enable diagnostic logging on the server --> <add key="Microsoft.LightSwitch.Trace.Enabled" value="false" /> <!-- A value of true only lets local access to Trace.axd --> <add key="Microsoft.LightSwitch.Trace.LocalOnly" value="true" /> <!-- The valid values for the trace level are: None, Error, Warning, Information, Verbose --> <add key="Microsoft.LightSwitch.Trace.Level" value="Information" /> <!-- A value of true will indicate that logging sensitive information is okay --> <add key="Microsoft.LightSwitch.Trace.Sensitive" value="false" /> <!-- The semi-colon separated list of categories that will be enabled at the specifed trace level --> <add key="Microsoft.LightSwitch.Trace.Categories" value="Microsoft.LightSwitch" /> <!-- A value of true will indicate http requests should be re-directed to https --> <add key="Microsoft.LightSwitch.RequireEncryption" value="False" /> <add key="ApplicationCulture" value="pt-br" /> </appSettings> <connectionStrings> <add name="_IntrinsicData" connectionString="Data Source=127.0.0.1;Initial Catalog=MyDB;Persist Security Info=True;User ID=sa;Password=123456" /> <add name="cdvReports" connectionString="Data Source=127.0.0.1;Initial Catalog=MyDB;Persist Security Info=True;User ID=sa;Password=123456" /> <add name="cdvData" connectionString="Data Source=127.0.0.1;Initial Catalog=MyDB;Persist Security Info=True;User ID=sa;Password=123456" /> </connectionStrings> <system.web> <!-- LightSwitch trace.axd handler --> <trace enabled="true" localOnly="false" requestLimit="40" writeToDiagnosticsTrace="false" traceMode="SortByTime" mostRecent="true" /> <httpHandlers> <add verb="GET" path="trace.axd" type="Microsoft.LightSwitch.WebHost.Implementation.TraceHandler,Microsoft.LightSwitch.Server.Internal,Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </httpHandlers> <httpModules> <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="LightSwitchModule" type="Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule,Microsoft.LightSwitch.Server.Internal,Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </httpModules> <compilation targetFramework="4.0"> <assemblies> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly="Microsoft.LightSwitch.Base.Server, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </assemblies> </compilation> <authentication mode="Forms"> <forms name="Cdv" timeout="120" /> </authentication> <sessionState timeout="120" /> <pages validateRequest="false"> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </controls> </pages> <!-- Setting maxRequestLength to be much greater than default 4096 so that large data may be uploaded e.g. images, docs --> <httpRuntime maxRequestLength="102400" requestPathInvalidCharacters="" requestValidationMode="2.0" /> <membership defaultProvider="AspNetMembershipProvider"> <providers> <clear/> <add name="AspNetMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="_IntrinsicData" applicationName="Cdv" requiresUniqueEmail="false" requiresQuestionAndAnswer="false" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="4" /> </providers> </membership> <roleManager enabled="True" defaultProvider="AspNetRoleProvider"> <providers> <clear/> <add name="AspNetRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="_IntrinsicData" applicationName="Cdv" /> </providers> </roleManager> <profile enabled="True" defaultProvider="AspNetProfileProvider"> <providers> <clear/> <add name="AspNetProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="_IntrinsicData" applicationName="Cdv" /> </providers> <properties> <add name="FullName" /> </properties> </profile> <customErrors mode="On" /> </system.web> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <providerOption name="CompilerVersion" value="v4.0" /> <providerOption name="WarnAsError" value="false" /> </compiler> </compilers> </system.codedom> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true"> <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="LightSwitchModule" preCondition="managedHandler" type="Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule,Microsoft.LightSwitch.Server.Internal,Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </modules> <handlers> <!-- LightSwitch trace.axd handler --> <add name="LightSwitchTrace" path="trace.axd" verb="*" type="Microsoft.LightSwitch.WebHost.Implementation.TraceHandler,Microsoft.LightSwitch.Server.Internal,Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </handlers> <defaultDocument> <files> <clear/> <add value="default.htm" /> </files> </defaultDocument> <security> <requestFiltering allowDoubleEscaping="true" /> </security> </system.webServer> <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> <behaviors> <serviceBehaviors> <behavior> <dataContractSerializer maxItemsInObjectGraph="6553600" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <webHttpBinding> <binding maxReceivedMessageSize="6553600" /> </webHttpBinding> </bindings> </system.serviceModel> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.LightSwitch" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="10.0.0.0-99.9.9.9" newVersion="10.0.11.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.LightSwitch.ExportProvider" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="10.0.0.0-99.9.9.9" newVersion="10.0.11.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.LightSwitch.Model.Xaml" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="10.0.0.0-99.9.9.9" newVersion="11.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> <uri> <schemeSettings> <add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes" /> <add name="https" genericUriParserOptions="DontUnescapePathDotsAndSlashes" /> </schemeSettings> </uri> </configuration>
3º After you publish your application. go to the [IIS] and see these settings.
Select your application in IIS and go to the yellow mark...
I use these settings in all my applications and delimit the time of 120 minutes. I never had problems with my clients. :)
-
Mittwoch, 4. Juli 2012 14:20
Hmm
I tried all above before.
I already have in my application like you and other earlier suggested Me.Details.ClientTimeout = 1000
I suppose there is something that I am missing on the IIS side. I already preset IIS Session Propertys to 120mins like you do.
It is interesting how app hangs out after precisely 5 mins.
This 5 mins is nowhere mentioned. Everywhere limit is set to 20mins by default.
So, even if we change it to 120mins, something else triggers after 5 mins inactivity.
Domagoj
-
Mittwoch, 4. Juli 2012 15:59
Do a test with the fiddler, let your app open and wait to see if there will be some request.
- Bearbeitet Yann DuranModerator Freitag, 8. Februar 2013 00:10 Fixed link text
-
Mittwoch, 4. Juli 2012 21:29
After 5 mins of inactivity, Fiddler captures this:
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom 38 200 HTTP gadgets.live.com /configW7.xml 636 max-age=31536000 text/xml sidebar:2924 GET /configW7.xml HTTP/1.1
Accept: */*
Accept-Language: hr
UA-CPU: AMD64
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET4.0C; .NET4.0E)
Host: gadgets.live.com
Connection: Keep-Alive
HTTP/1.1 200 OK
Cache-Control: max-age=31536000
Content-Type: text/xml
Content-Encoding: gzip
Last-Modified: Tue, 23 Jun 2009 21:56:41 GMT
Accept-Ranges: bytes
ETag: "80f2617d4df4c91:0"
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
P3P: CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"
Server: CO1MPPSTCA06
Date: Wed, 04 Jul 2012 21:10:57 GMT
Content-Length: 636
?If I try to continue working with application, I get red X where data can not be refreshed, Fiddler says:
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom 39 200 HTTP domagoj-bulat.from.hr /MyApp_2012/Web/LightSwitchApplication-Implementation-ApplicationDataDomainService.svc/binary/Sustavi_All?frameworkOperators=Include%3aModel&$where=(it.Korisnik.Id%253d%253d5)&$skip=0&$take=15&$includeTotalCount=True 739 no-cache Expires: -1 application/msbin1 iexplore:8432 <style>.REQUEST { font: 8pt Courier New; color: blue;} .RESPONSE { font: 8pt Courier New; color: green;}</style>GET /MyApp_2012/Web/LightSwitchApplication-Implementation-ApplicationDataDomainService.svc/binary/Sustavi_All?frameworkOperators=Include%3aModel&$where=(it.Korisnik.Id%253d%253d5)&$skip=0&$take=15&$includeTotalCount=True HTTP/1.1
Accept: */*
Referer: http://domagoj-bulat.from.hr/MyApp_2012/Web/MyApp_2012.Client.xap?v=1.0.33.0?v=1.0.33.0
Accept-Language: hr-HR
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Host: domagoj-bulat.from.hr
Connection: Keep-Alive
Cookie: MyApp_2012=B9146B4D1F3BBC47D1868E80E69564220E2E4C8DBB5AB8CFFC6F4F1C92851EEA40599C0618EE9437DB59C50297201757030E23F847DDBD7571C7CC6D2D3C671452A342CBD632A1471CDACC76093B1197A23D886E0AFB6B5A2A108ADDF68B1CC9005173DF2660E42B9C002518F1C09381CA826EE00CB65D39CBC41CA5F9A445957F59FE8FC77172A183A4C612D493F8127E4B36E1962EF00D82E22B3AF00A3529
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 739
Content-Type: application/msbin1
Expires: -1
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Wed, 04 Jul 2012 21:14:57 GMT
@Fault5http://schemas.microsoft.com/ws/2005/05/envelope/none@Code@Value?Sender@Reason@Textxmllang?en-US??<?xml version="1.0" encoding="utf-16"?><ExceptionInfo><Message>User does not have access to the invoked operation. Your session may have timed out. Please restart the application. Operation name: 'Sustavi_All'.</Message></ExceptionInfo>@Detail@DomainServiceFaultDomainServices i)http://www.w3.org/2001/XMLSchema-instance@ ErrorCode?@ ErrorMessage??<?xml version="1.0" encoding="utf-16"?><ExceptionInfo><Message>User does not have access to the invoked operation. Your session may have timed out. Please restart the application. Operation name: 'Sustavi_All'.</Message></ExceptionInfo>@IsDomainException?I was surprised to see it calls for gadgets.live.com
I guess it doesn't have to do anything with my app, it's just desktop gadgets request for their data :)
Domagoj
- Bearbeitet DomagojBulat Mittwoch, 4. Juli 2012 21:32
- Bearbeitet DomagojBulat Mittwoch, 4. Juli 2012 21:34
- Bearbeitet DomagojBulat Mittwoch, 4. Juli 2012 21:48
- Bearbeitet DomagojBulat Donnerstag, 5. Juli 2012 07:25
-
Donnerstag, 5. Juli 2012 03:56
the problem is the timeout of the session.
someone from microsoft could lend a hand here? -
Sonntag, 8. Juli 2012 01:54
@Domago. It smells like app pool retart issue which can wipe out your session state. If a hoster has idle timeout set to 5 minutes (for example), then the app pool will restart after 5 minutes if no requests. This is a double edge sword. It keeps processes from building up junk, but can cause these kinds of issues with client tokens. You may need to use their session state server to persist tokens between restarts and fix the machine key. I posted some thoughts on this before below.
Increase LS Timeouts.
1) SessionState Timeout is amount of time, in minutes, allowed between requests before the session-state provider terminates the session. Default is 20 minutes.2) Forms element Cookie timeout. Specifies the time, in minutes, after which the cookie expires. If slidingExpiration is true, the cookie timeout is extented another N minutes from the last request. For example if the timeout is 10 minutes, the time is extented another 10 minutes after each request. If the user makes no requests in last 10 minutes, the cookie will expire.
http://msdn.microsoft.com/en-us/library/1d3t3c61.aspx (This Topic Is No Longer Available)3) Add a machine key to the site. This ensures the client tokens are always validated with the same machine key even after an app pool restart. Otherwise the server will not validate the key and your token will expire giving you same effect as not increasing the session timeouts.
Example:
=====================
// Update Forms authentication and SessionState timeout in Web.Config.
// Please note IIS may define timeouts that can override the one defined in the app.<!--Increase Forms timeout and sessionState timeoutin Web.config in ServerGenerated folder.-->
<authentication mode="Forms">
<forms name="MyLSApp" timeout="120" />
</authentication>
<sessionState timeout="120"/>
<machineKey decryptionKey="63E80CCBFBCE2DF6D..."
validationKey="CFDAB9EF3CFB4750F1086D7C18871..." />
</system.web>
- Als Antwort vorgeschlagen Guillermo K Donnerstag, 7. Februar 2013 23:17
- Bearbeitet Yann DuranModerator Freitag, 8. Februar 2013 00:12 Fixed link text & added notice that the second link no longer works
- Bearbeitet Yann DuranModerator Freitag, 8. Februar 2013 00:13 Fixed text again
-
Donnerstag, 12. Juli 2012 08:44
I guess that is the answer, but due to my lack of experience I can't get it working properly yet. I have a lot to learn before I can get that right.
Thank you, Marden and William for taking your time to help me!
If someone fixes their timeout troubles with help from above posts, please mark as answered!
Domagoj
-
Donnerstag, 12. Juli 2012 09:40Moderator
Is this a LS 2011 project that's bee upgraded to LS 2012 RC?
If it is, then web.config file in the ServerGenerated folder won't be used (in fact the whole folder won't be used). LS 2012 RC does away with the two "generated" projects. That leaves the Client, Common, & Server projects. So the file you need to edit will be in the Server project, not the ServerGenerated project.
You can manually delete the two "generated" projects, they won't be used at all any more, but the upgrade process currently doesn't delete them.
Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands If you find a reply helpful, please click "Vote as Helpful", if a reply answers your question, please click "Mark as Answer" By doing this you'll help people find answers faster. -
Donnerstag, 12. Juli 2012 09:44
LS 2011, not upgraded.
I think maybe I need to set the Cookie timeout like William sugessted. I am on it, but it takes a while :)
Domagoj
-
Donnerstag, 12. Juli 2012 09:56Moderator
If it's a 2011 project, you're in the wrong forum. This is the LS 2012 RC forum. Until you just stated that it wasn't, I think anyone trying to answer would also have assumed that it was a LS 2012 RC project.Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands If you find a reply helpful, please click "Vote as Helpful", if a reply answers your question, please click "Mark as Answer" By doing this you'll help people find answers faster. - Als Antwort vorgeschlagen DomagojBulat Mittwoch, 1. August 2012 17:58
-
Mittwoch, 1. August 2012 17:58
Thanks, Yann!
I upgraded to LS 2012.
This solves problem with "freezing" page. After 5 mins inactivity, page asks user to login again.
There are no more red "x" all over application.
I tried to prolong this time, no success so far. It seems my trouble is at host's side. If I find something, I'll inform you.
Anyways, application now looks much better, and actually this is the answer to the 1st question here that WuZun asked.
Upgrading to 2012 will make forced logout/login after timeout automaticaly.
Thanks again everybody!
Btw. Yann, I am looking forward to your extension with working logout button :)
Domagoj
-
Donnerstag, 2. August 2012 05:31Moderator
Great to hear!
I haven't abandoned the extension, I just haven't had time to get back to it, after being sick for so long, then tryting to catch up on work, & answer questiosn here. So thanks for the reminder, I don't mind if you give me a kick, uhh, I mean "reminder" from time to time.
Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands If you find a reply helpful, please click "Vote as Helpful", if a reply answers your question, please click "Mark as Answer" By doing this you'll help people find answers faster.

