Using WebApi in orchard

Topics: Customizing Orchard, General, Writing modules
Aug 24, 2014 at 3:15 PM

Been playing with Web Api Controllers in MVC and I was hoping that I could just add an WebApiController to an orchard module set up a route in the global.ascx file and it would work.

I seem to be having no luck at all.

I have tried to add a web api controller to the main project but that just broke the entire application and I got a blank page.

I have a module with a web api controller in but I dont know the proper way or anyway to set up the route

where should I add this route?
        //            name: "API Default",
        //            routeTemplate: "api/{controller}/{id}",
        //            defaults: new { id = RouteParameter.Optional }
        //        );
Aug 24, 2014 at 5:21 PM
You can add your routes by implementing a class that implements IHttpRouteProvider in your module. See these posts for more information:
Aug 26, 2014 at 1:35 PM
Thank you for this it was spot on.

I actually tried this before but forgot to enable my module and presumed that it was deprecated... I would have been chasing my tail for days without your help.