HttpResponse.ClearContent not actually clearing content

idahboiz

New Member
I'm trying to prematurely end the execution of a page during the page_load, upon a certain condition, and in the course of trying to do a redirect it seems that ASP.NET is not actually clearing the response buffer and sending the buffered data alongside my redirect.Am I doing something wrong, or is there another way to suppress ASP.NET from handing off buffered output to IIS?\[code\]Protected Sub Redirect(ByVal url As String) If Response.BufferOutput Then Response.ClearHeaders() Response.ClearContent() End If Response.StatusCode = 301 Response.StatusDescription = "Moved Permanently" Response.Headers.Add("Location", url) Response.Write(String.Format("<html><head><script language=""text/javascript"">window.location.replace(""{0}"");</script></head></html>", url.ToJsString())) Response.Flush() HttpContext.Current.ApplicationInstance.CompleteRequest()End Sub\[/code\]Thank you for any help you might be able to offer!
 
Back
Top