Results 1 to 7 of 7

Thread: What happens to current thread execution after Response.Redirect???

Hybrid View

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    What happens to current thread execution after Response.Redirect???

    Say I have the following code:
    VB Code:
    1. Dim dt As New DataTable
    2.    'code to populate datatable
    3.    If dt.Rows.Count = 0 Then
    4.       Response.Redirect("NoRecords.aspx")
    5.    End If
    What happens to dt and the current thread execution?
    Say I did:
    VB Code:
    1. If dt.Rows.Count = 0 Then
    2.       Response.Redirect("NoRecords.aspx")
    3.       Dim Woof As Integer = 67
    4.    End If
    And place a break point on the Dim Woof line, then when u run the code it's clear that the Dim Woof line will NEVER get executed.
    This goes against all other synchronous and asynchronous calls, which will always return...someone will now ocme up with an example to go against what I said, but you know what I mean.
    So...what is actually happening here on the Redirect command?
    Does it start a new thread? If so, what happens to the old one? Is it left to the GAC to clear up?

    Woka

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: What happens to current thread execution after Response.Redirect???

    Everything on a page is 'destroyed' after the request is complete, even if there is no Response.Redirect. Therefore, moving to the next page or completing execution of the current one makes no difference in this context.

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: What happens to current thread execution after Response.Redirect???

    but what happens to thread execution, as normal functions would prosess the Response.Redirect, and then continue to the next line of code.
    What happens to this? Does the thread get toasted instantly?

    ie...if I have a connection open I shoudl do .close b4 I redirect blah blah blah.
    U have to write code around teh fact that the redirect function termintes the currect code execution...

    Woka

  4. #4

  5. #5
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: What happens to current thread execution after Response.Redirect???

    There is an overloaded method for Response.Redirect. You can specify whether to end the response on the current page -> http://msdn.microsoft.com/library/de...irectTopic.asp.

    Maybe worth a try - never used it myself though.

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  6. #6

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: What happens to current thread execution after Response.Redirect???

    Hmmmm very interesting. Damn, alredy given u a rep point, so can't give another. Doh!

    So, now for the nitty gritty questions. What overloaded method should you use?

    Woof

  7. #7
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: What happens to current thread execution after Response.Redirect???

    I would have thought:
    Code:
    Response.Redirect("http://www.somewhere.com/default.aspx", false);
    But like I said never tried it!

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width