|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/8/2010 Posts: 6 Location: Melbourne, Australia
|
Hi, I am trying to use CmsContext.ContentService.GetContentsByFolder in a ActionResult in a controller on a Ajax callback. The GetContentsByFolder call fails on Ajax call but succeeds on a normal view request by a link.
The only difference I can see on viewing the objects on debug is that the CMSContext property Cms_Application is null on the Ajax call and set on the link request.
Is this a bug? How can I get the content data on a Ajax call?
Regards Bruce
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 6/10/2010 Posts: 71 Location: Sweden
|
You can get the CmsContext by calling HttpContext.GetCmsContext() or alternatively pass it by using static / singleton. Though i dont think this is a pretty solution though in some cases its necessary (unless someone has a better solution). For example when using it in a way that an insatnce isnt created.
Though when its possible just pass this.CmsContext from the controller.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/8/2010 Posts: 6 Location: Melbourne, Australia
|
I can get the CmsContext, but on the ajax call the GetContent fails and exceptions a null. On a normal page request from a link the GetContent succeeds and returns the data.
The only difference I can see between the 2 is that the CmsContext has the property Cms_Application which is null in the ajax call and set in the normal link request.
I am stepping through the code to find the problem.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 6/10/2010 Posts: 71 Location: Sweden
|
I have done some module ajax calls but only for non kooboo CmsContext stuff, havent tried this before. Though no matter how you access the controller action you should get intellisense. I suppose your controller is inheriting ModuleController(or any baseclass that inturn has that inheritance)? I did a quick test on an old module code and i get intellisense for Cms_Application though i ran into null issues as well. Think it would be best to get a dev answer for this or perhaps someone with more kooboo experiance than i.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/2/2010 Posts: 122 Location: England
|
Hi brucek,
This works for me I can only guess that perhaps your url is wrong. Does your url contain the full path to the module for example :
/KooBoo_2_1_1_0/Site/c-ShootingSeeds/Contact/?ModuleUrl=mod_3060/Default/AjaxTest
/Contact/ is a page that contains the module as a component.
|
|
|
|
Guest
|