C
C
cicatrix2017-11-24 15:06:26
ASP.NET
cicatrix, 2017-11-24 15:06:26

How to configure request routing to ApiController in WebForms?

There is a legacy web application in WebForms (NOT MVC!)
It was necessary to attach an api (WebApiController web service) to it with requests like:
{url}/{api}/{action}
Created a web service inherited from ApiController

public class JobController : ApiController
{
        // GET api/<controller>
        public IEnumerable Get()
        {
            return "Hello, world!";
        }
}

In global.asax I wrote:
RouteTable.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{action}/{params}",
            defaults: new { controller = "Job", action = "get" }

the logic is such that if I go to webapp.com/api
, "Hello, world" should return,
of course, it does not work.
Question - how to properly configure the routing of requests to this service?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question