Access to ModuleID and PortalID in asmx webservice file in DotNetNuke

本小妞迷上赌 提交于 2019-12-10 23:16:24

问题


I have an asmx webservice file in my DotNetNuke module.How can I access to PortalID and ModuleID in this asmx file . when I try this code that works fine in code behinde .ascx.cs file it return portalID=0 , ModuleID=1

 private Components.Setting _ModuleSettings;
 _ModuleSettings = new Components.Setting(PortalId, ModuleId);

回答1:


Module settings require that you be within the context of a module. An .asmx service is not going to have that level of context.




回答2:


EDIT The below is still true, however the release of DNN 6.2 included the Services Framework which is specifically for the purpose of building web services in DNN. Services Framework is a much better solution than rolling your own .asmx based service.

/EDIT

Since you are executing a web service call and not a DNN module that context is not provided for you. However you can re-create it yourself. To get the current portal settings

var domainName = Globals.GetDomainName(request);
var alias = PortalAliasController.GetPortalAliasInfo(domainName);

return new PortalSettings(-1, alias);

Since your are not truly in the context of a page, the ActiveTab will fallback to a default (unless you can replace -1 with the active tabId).

To get the module context you will need to pass in the moduleId and tabId to your service and then call:

var module = new ModuleController().GetModule(moduleId, tabId)


来源:https://stackoverflow.com/questions/9158669/access-to-moduleid-and-portalid-in-asmx-webservice-file-in-dotnetnuke

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