M
moondaddy
I have some code I'm using from the OpenHack4 sample app from MS which
redirects a page to another page. Everytime I run the code I get an
exception, however the page still redirects to the correct page. I have
some other problems I'm trying to debug just after this code runs and I
don't know if they're somehow related to or effected by this exception, but
either way, I would like to get rid of the exception.
Here's the sub as is from MS (but I added the try/catch):
Friend Shared Sub RedirectWithMessage(ByVal url As String, ByVal message
As PageMessage)
Try
Dim cookie As New
System.Web.HttpCookie(Global.Session_PageMessage, message.ToString("d"))
Dim response As HttpResponse = HttpContext.Current.Response
response.Cookies.Add(cookie)
response.Redirect(url) 'Errors on this line
Catch ex As Exception
ErrLog(ex)
End Try
End Sub
ex is: {System.Threading.ThreadAbortException} System.Exception
and the StackTrace is:
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse)
at System.Web.HttpResponse.Redirect(String url)
at CharmPix.UrlHelper.RedirectWithMessage(String url, PageMessage message)
in c:\inetpub\wwwroot\CharmPix\Components\UrlHelper.vb:line 33" String
Is this supposed to happen? Can I avoid it? is there a better way?
redirects a page to another page. Everytime I run the code I get an
exception, however the page still redirects to the correct page. I have
some other problems I'm trying to debug just after this code runs and I
don't know if they're somehow related to or effected by this exception, but
either way, I would like to get rid of the exception.
Here's the sub as is from MS (but I added the try/catch):
Friend Shared Sub RedirectWithMessage(ByVal url As String, ByVal message
As PageMessage)
Try
Dim cookie As New
System.Web.HttpCookie(Global.Session_PageMessage, message.ToString("d"))
Dim response As HttpResponse = HttpContext.Current.Response
response.Cookies.Add(cookie)
response.Redirect(url) 'Errors on this line
Catch ex As Exception
ErrLog(ex)
End Try
End Sub
ex is: {System.Threading.ThreadAbortException} System.Exception
and the StackTrace is:
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse)
at System.Web.HttpResponse.Redirect(String url)
at CharmPix.UrlHelper.RedirectWithMessage(String url, PageMessage message)
in c:\inetpub\wwwroot\CharmPix\Components\UrlHelper.vb:line 33" String
Is this supposed to happen? Can I avoid it? is there a better way?