Laughing
普通解决方案增加webapi支持
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)
{
}
}
}
版权属于:
香草物语
本文链接:
https://www.xiangcaowuyu.net/java/common-solutions-add-web-api-support.html(转载时请注明本文出处及文章链接)
作品采用:
谢谢楼主。 666666
谢谢分享!