Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Stopping further processing with an Exit Sub in the Page_Load Event not working.

Reply
Thread Tools

Stopping further processing with an Exit Sub in the Page_Load Event not working.

 
 
Jason
Guest
Posts: n/a
 
      06-10-2004
I have an ASP.NET page that needs to use values set in session
variables to perform certain functions. I have code in the Page_Load
event that makes sure the session has not been restarted:

If Session.IsNewSession Then
Response.Write("<script>alert('Your session has
expired.');window.close();</script>")
Exit Sub
End If

This code does catch a "new" session, but processing continues if a
button has been clicked on the page to that event handler. Therefore,
I'm still getting an application error when that function is looking
for session variables that are now equal to nothing. Is there some
function other than Exit Sub that will stop all further processing if
a condition is met from the Page_Load event?
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      06-10-2004
Not sure, but if a routine is looking for a Session variable that hasn't
been set yet, you might be able to trap it like this:

If Session("variablename") is Nothing then
exit sub
End if

"Jason" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
>I have an ASP.NET page that needs to use values set in session
> variables to perform certain functions. I have code in the Page_Load
> event that makes sure the session has not been restarted:
>
> If Session.IsNewSession Then
> Response.Write("<script>alert('Your session has
> expired.');window.close();</script>")
> Exit Sub
> End If
>
> This code does catch a "new" session, but processing continues if a
> button has been clicked on the page to that event handler. Therefore,
> I'm still getting an application error when that function is looking
> for session variables that are now equal to nothing. Is there some
> function other than Exit Sub that will stop all further processing if
> a condition is met from the Page_Load event?


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U3RldmUgSw==?=
Guest
Posts: n/a
 
      06-10-2004
Jason - Have you tried just doing a Response.Redirect to send them to another page? If you want to stop the output at that point I believe you can use Response.end



"Jason" wrote:

> I have an ASP.NET page that needs to use values set in session
> variables to perform certain functions. I have code in the Page_Load
> event that makes sure the session has not been restarted:
>
> If Session.IsNewSession Then
> Response.Write("<script>alert('Your session has
> expired.');window.close();</script>")
> Exit Sub
> End If
>
> This code does catch a "new" session, but processing continues if a
> button has been clicked on the page to that event handler. Therefore,
> I'm still getting an application error when that function is looking
> for session variables that are now equal to nothing. Is there some
> function other than Exit Sub that will stop all further processing if
> a condition is met from the Page_Load event?
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
Materpage page_load event fired after content page_load? rockdale ASP .Net 1 11-16-2006 06:59 PM
Stop further execution in Page_Load Gopal Krish ASP .Net 2 10-25-2004 06:37 PM
keyword that stops further processing of a Python script Avi Kak Python 4 02-17-2004 03:08 PM



Advertisments