我们在使用DNN Platform 7.1.2的Azure网站上的Azure VM和生产环境中拥有一个开发站点。DnnApiController和Azure网站
下面看到的Ajax调用模式调用了DnnApicontroller并且在Dev站点上正常工作,但是在Azure网站上部署到生产站点后失败。
我检查了Bin文件夹,以确保两者都使用相同版本的dll。我检查了webconfig文件,发现它们也是类似的。
收到的错误是“{”消息“:”无法找到http://mydomain.com/DesktopModules/ContentModule/API/BusinessObjects/HelloWorld的控制器。在命名空间中搜索:IPW.Modules.ContentModule,ContentModule。“}”
这些调用在dev站点上正常工作。根据错误消息,路由没有发现名称空间提供的匹配控制器。
- 这是Ajax调用的示例:
$.ajax({
type: "POST",
cache: false,
url: baseServicePath + 'HelloWorld',
dataType: "json",
beforeSend: serviceFramework.setModuleHeaders
}).done(function (data) {
console.log(data);
}).fail(function() {
console.log('Sorry failed to load hours');
});
-the 'baseServicePath' 获得使用平台DNN serviceFramework.getServiceRoot( 'ContentModule')+ '论坛/'
URL - 所述routemapper:
public void RegisterRoutes(IMapRoute mapRouteManager) {
mapRouteManager.MapHttpRoute("ContentModule", "default", "{controller}/{action}", new[] { "My.Modules.ContentModule", "ContentModule" });
}
- 和apicontroller方法:
public class BusinessObjectsController : DotNetNuke.Web.Api.DnnApiController
{
[AllowAnonymous]
[AcceptVerbs("GET", "POST")]
public HttpResponseMessage HelloWorld()
{
string result = "Hello world! Time is: " + DateTime.Now + "";
var response = Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter);
return response;
}
}
}
呼叫失败的位置在Azure网站上运行的生产站点上,代码与开发者相同。 DNN平台正在使用自定义映射界面。任何建议表示赞赏。
感谢您的回复。我已经查看了自定义域设置,却没有发现任何问题。该网站已经运行了几个月,使用Azure自定义域名以及裸体和www。地址是有效的。使用您的ToDoList模块。我已经将它安装到dev和prod网站上。这两个webapi实例都按预期工作。所以,我不明白为什么ContentModule webapi不会。两者之间的代码模式具有可比性,并且使用从ContentModule视图到ToDoList控制器上的GetAll方法的ajax调用成功执行任何异常。 –
通常在注册名称空间时出现问题。我在routeMapper中看到了不同。在我的例子中,我只在新的[]中指定名称空间,而不是命名空间和控制器。还要确保routemapper类是公共的。确保你的开发环境中没有正确处理api调用的以前尝试的另一个程序集。最后,Fiddler在这里是你的朋友:检查你的开发环境中正在完成的调用,并与生产环境进行比较。 –