SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using SharePoint 2010. I have webparts, then when OK/Save/Cancel etc is clicked, it will redirect a user to the relevant page.

Over the past few months of writing different WebParts I have checked over my code and see that I'm using different ways of redirecting the user. My question is, which is the correct one to use and why?

share|improve this question
I like that you asked this kind of question. Sometimes subtle differences like this can be the hardest thing to find concrete information on. – Tom Resing Jun 26 '12 at 19:00
up vote 17 down vote accepted

I usually use SPUtility.Redirect when working with Application Pages or pages that need to potentially look at the source querystring or go back to settings.aspx.

If I am doing a redirect other times (usually in an HttpModule), I will use the Context.Response.Redirect or HttpContext.Current.Response.Redirect. The Page.Response.Redirect is just exposing the same object as Context.Response.Redirect, so they are essentially the same.

share|improve this answer
+1 for sharing relevant experience and putting the answer in context – Tom Resing Jun 26 '12 at 18:59

The difference between SPUtility.Redirect and Page.Response.Redirect is that SPUtility.Redirect provides many more options while redirecting. SPUtility.Redirect takes in the SPRedirectFlags enumeration as one of the parameters which gives us more control over the redirection. With it we can even keep the reference of the previous page.

More details on the SPUtility.Redirect over here:

And as Steve said, Page.Response.Redirect and Context.Response.Redirect are the same object.

share|improve this answer
+1 for the reference link and the detail on the flags. – Tom Resing Jun 26 '12 at 18:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.