ASP.NET Web Api in Web Forms

I am trying to use asp.net web api in WEB FORMS with visual studio 2010 (sp1) I did the following steps http://myrandomykien.blogspot.com/2012/02/simplest-web-api-site-with-nuget.html

When I use the visual studio development server , it works , but when I use iis 7.5, I get an HTTP 404.0 - Not Found error message.

Edit

This is my Global-asax

protected void Application_Start(object sender, EventArgs e) { RouteTable.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional } ); } 

This is the api class

 public class GreetingController : ApiController { public string GetGreeting(string id) { return String.Format("Hello {0}", id); } } 
+6
source share
1 answer

You must ensure that requests are continued without being redirected to ASP.NET, which by default is executed by your development server, but not IIS.

There are several possible approaches.

First, you can add runAllManagedModulesForAllRequests="true" to the module section of system.webServer . Some people claim that there are better methods, you can follow them:

http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html

+6
source

Source: https://habr.com/ru/post/909838/


All Articles