By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

Vb.net web application Timeout issue

P: 5
I have created a web application, and I want it to time out after a period of inactivity.
The web is hosted by godaddy, and has SQL server2005

In the Web.Config page I have added

<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="" cookieless="false" timeout="120"/>

<authentication mode="Forms">
<forms timeout="2"/>
</authentication>

I also have
<compilation debug="false" strict="false" explicit="true">

and in the form.load I have
Session.Timeout = 2

I've tried various combinations of these, but in no case does the application EVER TIMEOUT after any period of inactivity. I am new to this stuff and am surprised I've already gotten this far. What am I missing with getting it to timeout?
Jul 25 '08 #1
Share this Question
Share on Google+
8 Replies


kenobewan
Expert 2.5K+
P: 4,871
You may want to use a timer, however threading may also be of use. When your application timesout what do you want to happen?
Jul 25 '08 #2

P: 5
You may want to use a timer, however threading may also be of use. When your application timesout what do you want to happen?
I'd prefer to have the user redirected to the login page (login.aspx), but I don't understand why timeout doesn't have any effect.
I'm very new, and don't know what threading means.
Thanks for the reply
Jul 25 '08 #3

TRScheel
Expert 100+
P: 638
I'd prefer to have the user redirected to the login page (login.aspx), but I don't understand why timeout doesn't have any effect.
I'm very new, and don't know what threading means.
Thanks for the reply
Are you running the project in release? Or debug? I see that you set the setting but if you launch it in VS as debug it will override it.
Jul 25 '08 #4

P: 5
Are you running the project in release? Or debug? I see that you set the setting but if you launch it in VS as debug it will override it.
I compiled it and uploaded to the web, with the debug mode turned off. However I don't know if there are other settings that determine debug or release. What is VS ?
Jul 25 '08 #5

TRScheel
Expert 100+
P: 638
I compiled it and uploaded to the web, with the debug mode turned off. However I don't know if there are other settings that determine debug or release. What is VS ?
Sorry, Visual Studio. I am used to just referring to is as VS.

Could you post a sample web.config omitting secure lines with a sample login.aspx and inside page that requires logging in to see based off your code?

Again, emphasizing omitting secure lines. I dont need to see any sql connection strings, etc.
Jul 25 '08 #6

P: 5
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <configuration>
  3.  
  4.   <!--<appSettings>
  5.     <add key="connectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Projects\.......
  6.  
  7.   <appSettings>
  8.     '''connection string goes here.......    
  9.   </appSettings>
  10.  
  11.  
  12.  
  13.  
  14.   <system.web>
  15.    <!-- 
  16.             Set compilation debug="true" to insert debugging 
  17.             symbols into the compiled page. Because this 
  18.             affects performance, set this value to true only 
  19.             during development.
  20.  
  21.             Visual Basic options:
  22.             Set strict="true" to disallow all data type conversions 
  23.             where data loss can occur. 
  24.             Set explicit="true" to force declaration of all variables.
  25.         -->
  26.     <!--<sessionState timeout="1" mode="InProc" />--> 
  27.  <!--<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="" cookieless="false" timeout="120"/>-->
  28.     <!--<compilation debug="true" strict="false" explicit="true">-->
  29.     <compilation debug="false" strict="false" explicit="true">     
  30.     <assemblies>
  31.         <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  32.         <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  33.         <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  34.         <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  35.         <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  36.         <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  37.         <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  38.         <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  39.         <add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  40.         <add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  41.         <add assembly="System.DirectoryServices.Protocols, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  42.         <add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  43.         <add assembly="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  44.         <add assembly="System.Web.RegularExpressions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  45.       </assemblies>
  46.     </compilation>
  47.     <pages>
  48.       <namespaces>
  49.         <clear/>
  50.         <add namespace="System"/>
  51.         <add namespace="System.Collections"/>
  52.         <add namespace="System.Collections.Specialized"/>
  53.         <add namespace="System.Configuration"/>
  54.         <add namespace="System.Text"/>
  55.         <add namespace="System.Text.RegularExpressions"/>
  56.         <add namespace="System.Web"/>
  57.         <add namespace="System.Web.Caching"/>
  58.         <add namespace="System.Web.SessionState"/>
  59.         <add namespace="System.Web.Security"/>
  60.         <add namespace="System.Web.Profile"/>
  61.         <add namespace="System.Web.UI"/>
  62.         <add namespace="System.Web.UI.WebControls"/>
  63.         <add namespace="System.Web.UI.WebControls.WebParts"/>
  64.         <add namespace="System.Web.UI.HtmlControls"/>
  65.       </namespaces>
  66.     </pages>
  67.     <!--
  68.             The <authentication> section enables configuration 
  69.             of the security authentication mode used by 
  70.             ASP.NET to identify an incoming user. 
  71.         -->
  72.     <!--<authentication mode="Forms">
  73.       <forms timeout="2"/>
  74.     </authentication>-->
  75.     <authentication mode="Forms">
  76.       <forms loginUrl="Login.aspx" timeout="2"/>
  77.     </authentication>
  78.     <!--<authentication mode="Windows"/>-->
  79.  
  80.     <!--
  81.             The <customErrors> section enables configuration 
  82.             of what to do if/when an unhandled error occurs 
  83.             during the execution of a request. Specifically, 
  84.             it enables developers to configure html error pages 
  85.             to be displayed in place of a error stack trace.
  86.  
  87.         <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
  88.             <error statusCode="403" redirect="NoAccess.htm" />
  89.             <error statusCode="404" redirect="FileNotFound.htm" />
  90.         </customErrors>
  91.  
  92.         -->
  93.         <customErrors mode="Off"/>
  94.   </system.web>
  95. </configuration>
  96.  
Expand|Select|Wrap|Line Numbers
  1. default.aspx
  2. Page Load
  3.  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  4.         Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand
  5.         Dim oUser As pharm_users = New pharm_users(Page)
  6.         Dim oPatient As pharm_Patients = New pharm_Patients(Page)
  7.         Dim oConn As SqlClient.SqlConnection = Nothing
  8.         'Session.Timeout = 2
  9.         btnCancel.Attributes.Add("onClick", "return confirm('Press OK to abandon the data, or cancel to continue');")
  10.         btnSave.Attributes.Add("onClick", "return confirm('Press OK to Save and move to the next record');")
  11.         btnNoContact.Attributes.Add("onClick", "return confirm('Are you sure');")
  12.  
  13.         theChoiceNew = CInt(Session.Item("the_Choice"))
  14.         theCaller = CInt(Session.Item("Pharm_user_id"))
  15.         If Not Page.IsPostBack Then
  16.             If Not oUser.IsLogin() Then
  17.                 'Server.Transfer("./login.aspx")
  18.                                 Response.Redirect("https://www.sccpkh.com/login.aspx")
  19.                             Else
  20.  
etc....
Jul 25 '08 #7

Curtis Rutland
Expert 2.5K+
P: 3,256
Code tags are a requirement.

Please read the Posting Guidelines

MODERATOR
Jul 25 '08 #8

TRScheel
Expert 100+
P: 638
Looking at your code I cant find any reason why it wont work. I would suggest tearing it down and trying small samples like the below. Its in C# but the small segments of code should be fairly understandable from a VB .NET view. If you load the page the first time it will say "This should say Hello World" and if you refresh immediately it will say "Hello World". After a minute the session will timeout and reset the process. If your production server has the same result I would suspect there is more to your code than what you are showing, perhaps something holding the session or refreshing it.

web.config
Expand|Select|Wrap|Line Numbers
  1. <sessionState cookieless="true" timeout="1" mode="InProc" />
  2.  
default.aspx
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CollegeMain._Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7.     <title>Untitled Page</title>
  8. </head>
  9. <body>
  10.     <form id="form1" runat="server">
  11.     <div>
  12.  
  13.  
  14.         <asp:Label ID="lblMain" runat="server" Text="This should say Hello world!"></asp:Label>
  15.  
  16.     </div>
  17.     </form>
  18. </body>
  19. </html>
  20.  
default.aspx.cs
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.     if (Session != null)
  4.     {
  5.         if (Session["Test"] != null)
  6.         {
  7.             lblMain.Text = (string)Session["Test"];
  8.         }
  9.         else
  10.         {
  11.             Session.Add("Test", "Hello world!");
  12.         }
  13.     }
  14.     else
  15.     {
  16.         Session.Add("Test", "Hello world!");
  17.     }
  18.  
  19.     //Session.Timeout = 1;
  20.     /* uncomment the above and comment out the web.config line. Should have the same result */
  21. }
  22.  
Jul 25 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.