6

i´m trying to use the asp.net web api in WEB FORMS with visual studio 2010 (sp1) i have done this 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´m using iis 7.5 i get an Error HTTP 404.0 - Not Found.

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);
    }
}
1
  • could you provide more information? not much to go on right now. Commented Mar 2, 2012 at 16:24

1 Answer 1

6

You have to make sure that extensionless requests are routed to ASP.NET which is done by default by your development server but not IIS.

There are couple of possible approaches.

First, you could add runAllManagedModulesForAllRequests="true" in the modules section of the system.webServer. Some people claim there are better methods, you can then follow them:

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

Sign up to request clarification or add additional context in comments.

1 Comment

If someone is using iis in Classic mode, the Wiktor's solution don´t work, you have to install the extensionLess update for iis. support.microsoft.com/kb/980368

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.