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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0HOW TO: Get Current Portal Settings outside of HttpContextHOW TO: Get Current Portal Settings outside of HttpContext
Previous
 
Next
New Post
10/17/2007 11:03 AM
 

I am writing a Scheduler class that needs the current portal id.  I normally use the GetCurrentPortalSettings method of the PortalController class to do this.  However, I cannot in the Scheduler class, because the GetCurrentPortalSettings relies on the HttpContext for the settings.  (see example below)

Return CType(System.Web.HttpContext.Current.Items("PortalSettings"), DotNetNuke.Entities.Portals.PortalSettings)

Now, the Scheduler class runs outside of the HTTPContext, so I am unable to get this information.  I instead receive a NullReferenceException.  Does anyone have a clear and consistent way to retrieve the CURRENT Portal Id outside of the HttpContext?


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
10/17/2007 11:36 AM
 

There is no notion of a current portal Id if you are outside of an HTTP session.  The scheduler is a host function, and is not dependent on or run by a specfic portal.

Can you explain what you mean by the current portal id?


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
10/17/2007 12:13 PM
 

I have written scheduler items before, but they were more generic in nature.  This one is supposed to synchronize the Users with a custom Newsletter Module that we have.  However, in order to grab a list of users from the DataProvider, a PortalId is required.  Unfortunately, I cannot assume the portal id value.


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
10/17/2007 12:17 PM
 

So, are you wanting to do this for all portals, or is there a specific portal that requests or initiates this process for itself?  In the first case, you should be able to get all portals and run it for each one (using PortalController.GetPortals()).  In the second case, you'll need to persist the value of the requesting portal, probably in the database.  I've seen modules that have a table with a column for pertinent information for each job (in this case, PortalId), and then a value to indicate whether that job has been processed or not.

Does that work for you?


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
10/17/2007 12:27 PM
 

Another way to do this is to have your scheduled task execute an asynchronous web service that is part of your DNN application.  The web service will then be ran with the proper HttpContext so you'll be able to code the task normally.

The other advantage to creating a web service that runs in context is that you could also call it from an external scheduler or manually.


DotNetNuke Modules from Snapsis.com
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0HOW TO: Get Current Portal Settings outside of HttpContextHOW TO: Get Current Portal Settings outside of HttpContext


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