[英]How to Enable Webapi in Asp.net webforms Existing Project using iis?
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
System.Web.Routing.RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }
);
}
My existing Application done by Asp.net Webforms and i implements webapi that application for my another application.now i call webapi i got 404 error after publish in server.And i also include 我现有的由Asp.net Webforms完成的应用程序,我为另一个应用程序实现了该应用程序的webapi。现在我调用webapi,在服务器中发布后出现404错误。
<modules runAllManagedModulesForAllRequests="true" />
in web.config file.please help me 在web.config file.please帮助我
Your problem may be not related to the routing configuration, May be you are sending wrong web request. 您的问题可能与路由配置无关,可能是您发送了错误的Web请求。 Can you give us your web request sample here !? 您可以在这里给我们您的Web请求示例!
Anyway you just make sure this line of code exists in your application start : 无论如何,您只需确保应用程序开始中存在以下代码行:
GlobalConfiguration.Configure(WebApiConfig.Register);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.