IHttpActionResult 使用範例
舊的作法 public HttpResponseMessage Delete ( int id ) { var status = _Repository . DeleteCustomer ( id ); if ( status ) { return new HttpResponseMessage ( HttpStatusCode . OK ); } else { throw new HttpResponseException ( HttpStatusCode . NotFound ); } } Web API 2 作法 public IHttpActionResult SomeAction () { IHttpActionResult response ; //we want a 303 with the ability to set location HttpResponseMessage responseMsg = new HttpResponseMessage ( HttpStatusCode . RedirectMethod ); responseMsg . Headers . Location = new Uri ( "http://customLocation.blah" ); response = ResponseMessage ( responseMsg ); return response ; }