Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore: What is the advantage of Sitecore.Web.WebUtil.Redirect over Response.Redirect?

Is there any advantage or difference when using...

Sitecore.Web.WebUtil.Redirect(string path)

...instead of...

Response.Redirect(string url)

...for redirecting?

like image 596
Jake Avatar asked Jun 11 '12 16:06

Jake


1 Answers

There is one major difference. The Sitecore method will check that there is in fact a HttpContext. Other than that there is no difference as Sitecore.Web.WebUtil.Redirect(string path) in turn calls HttpContext.Current.Response.Redirect(path, true);

However, if you call Sitecore.Web.WebUtil.Redirect(path, false) and the path you provide is the same page you on then no redirect will happen.

like image 136
Sean Kearney Avatar answered Oct 18 '22 07:10

Sean Kearney