コード例 #1
0
        // GET api/verbs/5
        public IHttpActionResult Get([FromUri] int id)
        {
            var a = new Toto()
            {
                Hello = "World",
                Id    = id
            };

            // When returning object, ASP.NET chooses automatically the Formatter (serializer)
            // The formatter depends on Request Accept Header and returned payload type (serializable or not ?)
            return(Ok(a /*, Configuration.Formatters.JsonFormatter*/));
        }
コード例 #2
0
 // PUT api/verbs/5
 public IHttpActionResult Put(int id, [FromBody] Toto value)
 {
     return(Ok(("PUT", id, value)));
 }
コード例 #3
0
 // POST api/verbs
 public IHttpActionResult Post([FromBody] Toto value)
 {
     return(Ok(("POST", value)));
 }