Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

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

 
Thread Tools Search this Thread
Old 06-10-2004, 01:23 PM   #1
Default Stopping further processing with an Exit Sub in the Page_Load Event not working.


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?


Jason
  Reply With Quote
Old 06-10-2004, 02:30 PM   #2
Ken Cox [Microsoft MVP]
 
Posts: n/a
Default Re: Stopping further processing with an Exit Sub in the Page_Load Event not working.
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" <> wrote in message
news: 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?




Ken Cox [Microsoft MVP]
  Reply With Quote
Old 06-10-2004, 02:36 PM   #3
=?Utf-8?B?U3RldmUgSw==?=
 
Posts: n/a
Default RE: Stopping further processing with an Exit Sub in the Page_Load Even
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?
>



=?Utf-8?B?U3RldmUgSw==?=
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing ASP.Net Modal dialog window after serverside event processing alienworkshop Software 0 08-17-2006 09:45 AM
"The biggest scandal to ever hit American politics" Jas DVD Video 149 12-05-2004 02:47 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46