Adding services framework (web api) to DNN7 module

左心房为你撑大大i 提交于 2019-12-11 02:18:45

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19203815/adding-services-framework-web-api-to-dnn7-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!