1.自定义路由 public static class WebApiConfig { public static void Register(HttpConfiguration config) { // Web API 路由 config.MapHttpAttributeRoutes(); //1.默认路由 config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}…
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Web.Http; namespace iAttendance.Controllers{ public class UsersController : ApiController { // GET api/users public IEnumerable<Users> GetUserList() { usin…
1.当我们创建WebApi的时候我们的项目下的Contorls文件夹下的ValuesController文件下会出现这么几个方法: // GET http://程序ip:程序端口/api/values public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET http://程序ip:程序端口/api/values/5 public str…