Prasanna Kumar J
Prasanna Kumar J

Reputation: 1598

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

  <modules runAllManagedModulesForAllRequests="true" />

in web.config file.please help me

Upvotes: 0

Views: 447

Answers (1)

Mohammad Nikravesh
Mohammad Nikravesh

Reputation: 975

Your problem may be not related to the routing configuration, May be you are sending wrong web request. Can you give us your web request sample here !?
Anyway you just make sure this line of code exists in your application start :

GlobalConfiguration.Configure(WebApiConfig.Register);

Upvotes: 1

Related Questions