Response.Redirect in Catch

HardCode

Freshman
Joined
Apr 2, 2004
Messages
49
I am confused about why, when I uncomment the Response.Redirect in the Catch, the page always .Redirects to "autherror.aspx". If it is commented, the page works fine! Is a .Redirect allowed in a Catch? If not, why does it .Redirect to that page every time when uncommented!
Code:
Try
    ' Code that works and redirects to appropriate page
    ' based on a series of checks

Catch e As Exception
    'Response.Redirect("autherror.aspx")

Finally
    oConn.Close

End Try
 
I don't believe so, because if I comment out the lines: Try, Catch, Finally, End Try there is no error on the page. Since I use Web Matrix, I use the "technique" of commenting out the error handling to see any errors in the web browser (debug="true" is set). When I do so now, there is no error. That is why it is confusing me. It seems the parser just doesn't like that one .Redirect in the Catch !?!
 
If you have a Try Catch Finally ... there won't be any error shown in the browser.

My advice....

-Insert Response.Write(e.Message) inside your Catch.
-Put a break point in the beginning of you try and do a step-to-step until it goes out of your try and goes right into the catch.

When did it goes out ? Catch shall be called only when there's an Exception thrown. And Finally is always called.

Tell me more on your problem.
 
If you have a Try Catch Finally ... there won't be any error shown in the browser.

Yes, that why I commented them out and still received no error. :)

I am using Web Matrix so I cannot step through :( ... UNLESS, you can help me with the other thread I posted about VS.NET 2003 + IIS with that "...IIS is not running ASP.NET 1.1" error! :)
 
That's why I said to insert a Response.Write(e.Message) inside the Catch section and to leave your Redirect commented.

Tell us the error that is shown.

Thank you
 
My other thread doesn't really explain why this code is causing the exception code to kick in. Right now, management has links to my alpha version of the web app, so I cannot try the changes. Later in the day I will add the Response.Write(e.Message) and see what it produces. Thanks!
 
Back
Top