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 StartedAccessing ModuleSettings from DNNApiControllerAccessing ModuleSettings from DNNApiController
Previous
 
Next
New Post
2/25/2013 2:08 PM
 

Hi.

I am having troubles accessing my module setting from inside a controller class inheriting DnnApiController

for example I can access my settings in my view.ascx.cs with the following 

var URL = Settings["SuccessURL"].toString();

but can not use the same in the controller class so I tried to implement an IDisposable 

using(ContactsManagerModuleSettingsBase cmms = new ContactsManagerModuleSettingsBase())
                    {
                        var response = Request.CreateResponse(HttpStatusCode.Moved);
                        response.Headers.Location = new Uri(cmms.Settings["SuccessURL"].ToString());
                        return response;
                    }

Here it would seem to work but when the code fires I have a NullReference Exception. I also notice that the count for settings is 0

Does anyone know how I might do get the settings?

Thank you

Mark 

 
New Post
3/1/2013 12:26 PM
 
This answer was provided by William Severance on the dnn community exchange site.

Mark,

It's actually much simpler than you're making it . . . Assuming that your ajax request is already setting the ModuleId and TabId in it's beforeSend callback using the service framework's plugin function setModuleHeaders, you will find that within your custom service controller's methods the ActiveModule property (ModuleInfo object) is already set for you. ActiveModule exposes both the module's ModuleSettings and TabModuleSettings hash tables. So, you should be able to write:

var URL = ActiveModule.ModuleSettings["SuccessURL"].ToString();

Note that unlike the Settings hash table exposed by PortalModuleBase or ModuleSettingsBase which combines ModuleSettings and TabModuleSettings to create the Settings hashtable the ActiveModule property exposes settings as two separate hash tables.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedAccessing ModuleSettings from DNNApiControllerAccessing ModuleSettings from DNNApiController


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