title: Redirect to another URL from a WCF REST function without returning HTTP 302
body: <p>I have a REST service that gets a GET request, and I want it to be able to redirect to one of three urls, without having to send an <code>http 302</code> error and the new url.</p>
  
  <pre><code>    [OperationContract(Name = "MyService")]
      [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/myservice/{option}")]
      public System.IO.Stream MyService(String option)
  </code></pre>
  
  <p>This is how I have it defined, but when I look at <code>WebOperationContext.Current.OutgoingResponse</code> I don't have a method for redirect.</p>
  
  <p>Is there any way to do this automatically?  The reason I am hoping to do this is that this webservice may be called by a program, and it would be simpler on the program to not have to catch the 302 error and then do the redirect manually.</p>
  
  <p>It appears the correct way is to follow this:
  <a href="http://christopherdeweese.com/blog2/post/redirecting-from-a-wcf-rest-service" rel="nofollow">http://christopherdeweese.com/blog2/post/redirecting-from-a-wcf-rest-service</a></p>
  
  <p>and do this:</p>
  
  <pre><code>WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Redirect;
  WebOperationContext.Current.OutgoingResponse.Location = "/someOtherPage.aspx";
  return null; 
  </code></pre>
  
  <p>I just hope to find another solution.</p>