Jake
Jake

Reputation: 4899

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?

Upvotes: 5

Views: 3467

Answers (1)

Sean Kearney
Sean Kearney

Reputation: 4008

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.

Upvotes: 12

Related Questions