TypechoJoeTheme

香草物语

统计
登录
用户名
密码
/
注册
用户名
邮箱
输入密码
确认密码

普通解决方案增加webapi支持

Laughing博主
2019-05-17
/
0 评论
/
1,142 阅读
/
13 个字
/
百度已收录
05/17
本文最后更新于2021年04月27日,已超过1241天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

添加程序集

System.Net.Http
System.Net.Http.Formatting
System.Web.Http
System.Web.Http.Common
System.Web.Http.WebHost

增加全局配置文件Global.asax

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.Http;  
using System.Web.Mvc;  
using System.Web.Routing;  
using System.Web.Security;  
using System.Web.SessionState;  
  
namespace WebApplication4  
{  
    public class Global : System.Web.HttpApplication  
    {  
  
        protected void Application_Start(object sender, EventArgs e)  
        {  
            AreaRegistration.RegisterAllAreas();  
            RouteTable.Routes.MapHttpRoute(  
     name: "DefaultApi",  
     routeTemplate: "api/{controller}/{id}",  
     defaults: new  
     {  
         id = RouteParameter.Optional  
     });  
        }  
  
        protected void Session_Start(object sender, EventArgs e)  
        {  
  
        }  
  
        protected void Application_BeginRequest(object sender, EventArgs e)  
        {  
  
        }  
  
        protected void Application_AuthenticateRequest(object sender, EventArgs e)  
        {  
  
        }  
  
        protected void Application_Error(object sender, EventArgs e)  
        {  
  
        }  
  
        protected void Session_End(object sender, EventArgs e)  
        {  
  
        }  
  
        protected void Application_End(object sender, EventArgs e)  
        {  
  
        }  
    }  
}
webapi
朗读
赞(1)
赞赏
感谢您的支持,我会继续努力哒!
版权属于:

香草物语

本文链接:

https://www.xiangcaowuyu.net/java/common-solutions-add-web-api-support.html(转载时请注明本文出处及文章链接)

评论 (0)
  1. 666 闲逛
    Windows 10 · Google Chrome

    谢谢楼主。 666666

    2020-09-11 回复
  2. gh 闲逛
    MacOS · Safari

    谢谢分享!

    2019-08-23 回复