Monday, December 1, 2008

Launch an external application

Dim MyProcess As New System.Diagnostics.Process  
   MyProcess.StartInfo.CreateNoWindow = True  
   MyProcess.StartInfo.UseShellExecute = True  
   MyProcess.StartInfo.WorkingDirectory = "C:\MyDirectory"  
   MyProcess.StartInfo.FileName = "MyApplication.exe"  
   MyProcess.StartInfo.Arguments = "MyArgument"  
   MyProcess.Start()

ASP.NET: Redirect the page when the session ends

Here's a simple method, without using javascript, to redirect the user to a certain page once their session ends:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Response.AppendHeader("Refresh", (Session.Timeout * 60) + 5 & "; Url=SessionEnded.aspx")
End If
End Sub