标签:主程序 情况 宿主程序 启动服务 builder 控制 使用 post static
public class UserController: ApiController { [HttpPost,HttpGet] public string PostGetInfo() { return "API测试地址"; } }
static void Main(string[] args) { var config = new HttpSelfHostConfiguration("http://localhost:8083"); config.Routes.MapHttpRoute( "API Default", "api/{controller}/{id}", new { id = RouteParameter.Optional }); using (var server = new HttpSelfHostServer(config)) { server.OpenAsync().Wait(); Console.WriteLine("Press Enter to quit."); Console.ReadLine(); } }
public class UserController: ApiController { [HttpPost,HttpGet] public string PostGetInfo() { return "API测试地址"; } }
public class Startup { public void Configuration(IAppBuilder appBuilder) { HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); appBuilder.UseWebApi(config); } }
static void Main(string[] args) { string baseAddress = "http://localhost:9000/"; // 启动 OWIN host WebApp.Start<Startup>(url: baseAddress); Console.WriteLine("程序已启动,按任意键退出"); Console.ReadLine(); }
标签:主程序 情况 宿主程序 启动服务 builder 控制 使用 post static
原文地址:http://www.cnblogs.com/xiangchangdong/p/6768249.html