标签:self local ati ESS 关闭 exce pre web api ram
using System; using System.Web.Http; using System.Web.Http.SelfHost; namespace UAC_OAuth2Center { public class Program { static void Main(string[] args) { try { var config = new HttpSelfHostConfiguration("http://localhost:2021"); // Web API 配置和服务 config.EnableCors(new System.Web.Http.Cors.EnableCorsAttribute("*", "*", "*", "*")); //config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute(name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional }); using (var sever = new HttpSelfHostServer(config)) { sever.OpenAsync().Wait(); Console.WriteLine("SPC_Server服务已经成功启动!"); Console.WriteLine("输入任意字符关闭"); Console.Read(); sever.CloseAsync().Wait(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); } } }
记住,启动VS 的时候,使用管理员权限启动
标签:self local ati ESS 关闭 exce pre web api ram
原文地址:https://www.cnblogs.com/ingstyle/p/11804353.html