title: ASP.NET API Controller POST/Redirect/Get
body: <p>I would like to use the P/R/G design with this API, using AngularJS on the client side.  Here is my API method:</p>
  
  <pre><code>    [HttpPost]
      public HttpResponseMessage UpdateRaw(HttpRequestMessage request)
      {
         //do stuff...
  
          var res = request.CreateResponse(HttpStatusCode.Redirect);
  
          var authority = request.RequestUri.Authority;
          var uri = string.Concat(authority, "/api/DataApi/GetRaw");
  
          res.Headers.Location = new Uri(uri);
  
          res.Headers.Add("Access-Control-Allow-Origin", "*");
          return res;
      }
  </code></pre>
  
  <p>I have another method in this controller (<code>DataApiController</code>) which is called <code>GetRaw()</code>.  Basically I want the client to issue a POST, call this method, then get redirected to the GET method.  Here is my JS code:</p>
  
  <pre><code>//get the data and build the js rep
          $http({
              method: 'POST',
              url: '/api/DataApi/UpdateRaw',
              headers: {
                  'Content-Type': undefined
              },
              data: {
                  test: "test"
              }
          }).then(function (result) {
              console.log("RAW--------------");
              console.log(result.data);
  
              // do stuff...
  
          }, function () { console.log("DIDN'T WORK"); });
  </code></pre>
  
  <p>When I issue the POST, however, my browser console says "<code>The request was redirected to a URL ('localhost:25498/api/DataApi/GetRaw') which has a disallowed scheme for cross-origin requests.</code>"  I am aware of <a href="https://stackoverflow.com/questions/11324711/redirect-from-asp-net-web-api-post-action">this</a> answer, but that had the same result.</p>
  
  <p>I found another website somewhere which suggested adding the line </p>
  
  <p><code>res.Headers.Add("Access-Control-Allow-Origin", "*");</code></p>
  
  <p>but that does not seem to work either.</p>
  
  <p>I am new to ASP.NET and Web Dev in general, so any ideas would be appreciated.  Thanks.</p>