home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / 24 aspnet applications / aspnetapplications / redirectpage.aspx.vb < prev    next >
Encoding:
Text File  |  2002-03-18  |  1.5 KB  |  43 lines

  1. ' this page is just an example of how you can create a generic
  2. ' redirection scheme in your application. If you pass a URL to the
  3. ' query string for this page, execution will jump to that page, but
  4. ' you have the opportunity to update your counters and other stats.
  5.  
  6. Public Class RedirectPage
  7.     Inherits System.Web.UI.Page
  8.  
  9. #Region " Web Form Designer Generated Code "
  10.  
  11.     'This call is required by the Web Form Designer.
  12.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  13.  
  14.     End Sub
  15.  
  16.     Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  17.         'CODEGEN: This method call is required by the Web Form Designer
  18.         'Do not modify it using the code editor.
  19.         InitializeComponent()
  20.     End Sub
  21.  
  22. #End Region
  23.  
  24.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  25.         ' Read the targer URL on the query string.
  26.         Dim url As String = Request.QueryString("url")
  27.  
  28.         ' increment the number of redirections so far.
  29.         Dim appVarName As String = "redirections_count"
  30.         Application.Lock()
  31.         If Application(appVarName) Is Nothing Then
  32.             Application(appVarName) = 1
  33.         Else
  34.             Application(appVarName) = CInt(Application(appVarName)) + 1
  35.         End If
  36.         Application.UnLock()
  37.  
  38.         ' redirect to the specified URL (must be on this web server).
  39.         Server.Transfer(url)
  40.     End Sub
  41.  
  42. End Class
  43.