public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
public class ValueController : ApiController
{
// GET api/value
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/value/5
public string Get(int id)
{
return "value";
}
// POST api/value
public void Post([FromBodystring value)
{
}
// PUT api/value/5
public void Put(int id, [FromBodystring value)
{
}
// DELETE api/value/5
public void Delete(int id)
{
}
}
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |