Quantcast
Channel: Ryan Bailey Development
Viewing all articles
Browse latest Browse all 287

IHttpHandler response redirect shows Object moved to here

$
0
0
While working on a HTTP Handler for PDF files, I found that redirecting to a new URL would display:
Object moved to here.
 This was using the following code:

context.Response.Redirect(pdfUrl, false);
context.Response.StatusCode = 301;
context.Response.End();

This could have been related to the redirect begin inside a try catch block, so the following code works better by flushing a redirect header.

HttpResponse Response = HttpContext.Current.Response;
Response.StatusCode = 301;
Response.StatusDescription = "Moved Permanently";
Response.RedirectLocation = pdfUrl;
Response.Flush();

This then worked as expected.

Viewing all articles
Browse latest Browse all 287