Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do an HTTP 307 redirect

For technical reasons we need to perform an HTTP 307 redirect instead of a 302.

For 302's I'd do:

HttpContext.Current.Response.Redirect(url)

For 301's I do:

HttpContext.Current.Response.RedirectPermanent(url)

How would I implement a 307?

like image 391
Tom Gullen Avatar asked Dec 14 '25 04:12

Tom Gullen


1 Answers

Solved this by adding a location header and doing redirect manually:

                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.StatusDescription = "Temporary Redirect";
                    HttpContext.Current.Response.AddHeader("Location", redirectURL);
                    HttpContext.Current.Response.End();
like image 76
Tom Gullen Avatar answered Dec 16 '25 20:12

Tom Gullen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!