tatigo
tatigo

Reputation: 2254

Adding services framework (web api) to DNN7 module

I'm trying to integrate the Web API into DNN7 module.

Controller & Mapper:

namespace MyControllers
{
    public class ExampleController : DnnApiController
        {
            #region "Web Methods"
            [DnnAuthorize()]
            [HttpGet()]
            public HttpResponseMessage HelloWorld()
            {
                try
                {
                    string helloWorld = "Hello World!";
                    return Request.CreateResponse(HttpStatusCode.OK, helloWorld);
                }
                catch (System.Exception ex)
                {
                    //Log to DotNetNuke and reply with Error
                    Exceptions.LogException(ex);
                    return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
                }
            }


    public class RouteMapper : IServiceRouteMapper
        {
            public void RegisterRoutes(IMapRoute mapRouteManager)
            {
                mapRouteManager.MapHttpRoute("MyControllers", "default", "{controller}/{action}", new[] { "MyControllers" });
            }
        }
}

Then I'm trying to access the HelloWorld method from the url

https://localhost/DesktopModules/MyControllers/API/Example/HelloWorld

and getting the

HTTP Error 404.0 - Not Found

Any suggestions on what can be missing?

Upvotes: 2

Views: 1679

Answers (1)

tatigo
tatigo

Reputation: 2254

Solved!!! Turned out that the DesktopModules folder was as Application in IIS, which blocked the WebApi. So, if you get the non descriptive

HTTP Error 404.0 - Not Found

check the IIS first.

Upvotes: 1

Related Questions