WebAPI_使用控制台启动
WebAPI 启动 控制台 使用
2023-09-27 14:21:27 时间
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 的时候,使用管理员权限启动
相关文章
- 你所不知道的ASP.NET Core MVC/WebApi基础系列(一)
- ASP.NET Core MVC/WebAPi如何构建路由?
- ASP.NET WebAPi之断点续传下载(下)
- asp.net core程序发布(Webapi,web网站)
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十四)
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十二)
- 关于wcf,webservice,webapi或者其他服务或者接口有什么区别 WCF、WebAPI、WebService之间的区别 【转载】HTTP和SOAP完全就是两个不同的协议 WebService学习总结(一)——WebService的相关概念
- 结合jquery的前后端加密解密 适用于WebApi的SQL注入过滤器 Web.config中customErrors异常信息配置 ife2018 零基础学院 day 4 ife2018 零基础学院 day 3 ife 零基础学院 day 2 ife 零基础学院 day 1 - 我为什么想学前端
- 【WebApi系列】浅谈HTTP在WebApi开发中的运用
- c#中WepAPI(post/get)控制器方法创建和httpclient调用webAPI实例
- 开源组件websocket-sharp中基于webapi的httpserver使用体验
- webapi 异步返回
- 七、WebApi跨域操作
- 二、IIS通过发布方式部署WebApi
- asp.net core webapi 跨域中间件
- ajax 调用 java webapi 多个参数(一)
- easyui webapi
- Linux(CentOS 6.7)下配置Mono和Jexus并且部署ASP.NET MVC3、4、5和WebApi(跨平台)
- Jmeter调用Webapi介绍
- WebApi 接口参数不再困惑:传参详解