我正在尝试将 Web API 集成到 DNN7 模块中。
控制器和映射器:
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" });
}
}
}
然后我试图从 url 访问 HelloWorld 方法
https://localhost/DesktopModules/MyControllers/API/Example/HelloWorld
并得到
HTTP 错误 404.0 - 未找到
关于可能缺少什么的任何建议?