2

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);
atabrizi
  • 908
  • 1
  • 13
  • 29

2 Answers2

4

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)
ScottS
  • 8,455
  • 3
  • 30
  • 50
3

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

Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173