Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting Startedway to access to PortalIdway to access to PortalId
Previous
 
Next
New Post
6/1/2011 3:21 PM
 
Hi... I'm developing a scheduled task and need to obtain the current portal Id, I've tried with:
int portalId = PortalController.GetCurrentPortalSettings().PortalId;
it throws an excepcion reference to an object not set as object instance
when I try this:
PortalController objportalcont = new PortalController();
int portalId = objportalcont.GetCurrentPortalSettings().PortalId;
appears a warning that says this member can´t be accesed as reference it must be do as type name. Wich is the correct usage of PortalController.GetCurrentPortalSettings(), or other way to access to PortalId. Thanks.
 
New Post
6/1/2011 6:44 PM
 
if you instanciate a portal controller, it needs to be populated - or you need to use environment values instead.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
6/1/2011 7:30 PM
 
Hi Sebastian do you have an example about how populate a PortalController and wich enviroment variables do you suggest to use, because through scheduler client class I can't access portalId directly. Thanks by your quick answer.
 
New Post
6/1/2011 10:36 PM
 
A scheduled task does not have a current HttpContext on which the PortalSettings object (including PortalID) is passed during a normal user request. You will need to include either the PortalID (or ModuleID or TabID from which PortalID can be determined) as part of your data (in a custom database table etc) on which the scheduled task will be operating. Depending on what work you are performing during the execution of the scheduled task you may actually need to construct your own mock HttpContext and create your own PortalSettings instance that is added to this HttpContext's Items collection - not a trivial task.

Try a Google search on "DotNetNuke scheduled task PortalSettings" and you should be able to find some discussion (particularly from Bruce Chapman) on this issue.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
6/2/2011 5:36 PM
 
Thanks. I wrote my own method because I need only the portalId.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting Startedway to access to PortalIdway to access to PortalId


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out