using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using System.Web.Mvc; using Newtonsoft.Json; namespace xUnitStudy.WebApi.Controllers { public class ValuesController : ApiController { // GET api/values public IEnumerable Get() { return new string[] { "value1", "value2" }; } [System.Web.Http.Authorize] public string Get(int id) { return id.ToString(); } // POST api/values public IHttpActionResult Post([FromBody]string value) { var cc = new System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult ( "", new Dictionary { { "id",2} }, "", this ); return cc; } // PUT api/values/5 public void Put(int id, [FromBody]string value) { } // DELETE api/values/5 public void Delete(int id) { } } }