简体   繁体   English

如何使用iis在Asp.net Webforms现有项目中启用Webapi?

[英]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.

相关问题 如何在ASP.NET WebForms网站项目中启用实体框架 - How to enable Entity Framework in a ASP.NET WebForms Website Project 如何使用IIS上的当前版本托管asp.net webapi项目 - How to host asp.net webapi project with the current build on IIS 如何通过使用现有的Asp.net C#项目功能开发要在Android App中使用的WebAPI - How to Develop WebAPI to be used in Android App by using existing Asp.net C# project functions 将Typescript添加到现有asp.net 4 Webforms项目的推荐方法 - Recommended way to add Typescript to an existing asp.net 4 Webforms project 如何在iis8中启用asp.net - How to enable asp.net in iis8 如何在ASP.NET Web窗体中启用水平拖放? - How to enable horizontal drag-drop in asp.net webforms? 在同一工作进程中运行ASP.NET WebForms项目和WebAPI项目 - Running ASP.NET WebForms project and WebAPI project in the same worker process 如何在ASP.NET Webforms网站项目中一起使用Webforms和ASP.NET MVC? - How do I use Webforms and ASP.NET MVC together in an ASP.NET Webforms Website project? 在ASP.NET Webforms中使用FormsAuthentication时如何禁用或启用cookie? - How to disable or enable cookie when using FormsAuthentication in ASP.NET webforms? Asp.net WebForms启用角色 - Asp.net WebForms Enable Roles
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM