添加服务框架(网页API)来DNN7模块 [英] Adding services framework (web api) to DNN7 module
本文介绍了添加服务框架(网页API)来DNN7模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在Web API集成到DNN7模块。
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" });
}
}
}
然后我试图从URL访问的HelloWorld方法
Then I'm trying to access the HelloWorld method from the url
https://localhost/DesktopModules/MyControllers/API/Example/HelloWorld
和获得
HTTP错误404.0 - 找不到
HTTP Error 404.0 - Not Found
这是什么可以缺少任何建议?
Any suggestions on what can be missing?
推荐答案
解决!原来那DesktopModules文件夹是在IIS中,应用程序,它挡住了的WebAPI。
所以,如果你得到的非描述性的
Solved!!! Turned out that the DesktopModules folder was as Application in IIS, which blocked the WebApi. So, if you get the non descriptive
HTTP错误404.0 - 找不到
HTTP Error 404.0 - Not Found
检查IIS第一。
这篇关于添加服务框架(网页API)来DNN7模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文