.NETJiNi@jigneshdesai.com  
  Home |  .NET<1.0 to 3.5> Forums Blogs |  Other Technologies Skip Navigation Links  | Quiz Contest   dotnetJini Training |   Software Development 
   
Topic : Force a initial page for users
Author : Jignesh Desai Total Visits: 202
Published Date: Thursday, May 04, 2000  

<SCRIPT RUNAT=Server Language=VBScript>
Sub Session_OnStart
' Make sure that new users start on the correct page of the ASP application.

' Replace the value given to startPage below with the virtual path to your application's
' start page.

startPage = "/MyApp/StartHere.asp"
currentPage = Request.ServerVariables("SCRIPT_NAME")

' Do a case-insensitive compare, and if they
' don't match, send the user to the start page.

if strcomp(currentPage,startPage,1) then
Response.Redirect(startPage)
end if
End Sub
</SCRIPT>


The preceding example only works for browsers that support cookies. Because a noncookie browser does not return the SessionID cookie, the server creates a new session each time the user requests a page. Thus for each request, the server processes the Session_OnStart script and redirects the user to the starting page. If you use the script below, it is recommended that you put a notice on your starting page to inform users that the site requires a cookie-enabled browser.

Remarks
You should note that any Session_OnStart event script that follows a call to the Redirect method is not executed. For this reason, you should call the Redirect method last in your event script. This is demonstrated in the following example. 

<SCRIPT LANGUAGE=VBScript RUNAT=Server> 
Sub Session_OnStart
' Session initialization script 
Response.Redirect "http:/server/app/StartHere.asp"
End sub
</SCRIPT>









 
   
   
   
Add URL | About ME Privacy Policy | Legal Disclaimer

Copyright (C) 2004 -2008 JigneshDesai.com. All rights reserved