Problem retrieving published contents using UmbracoApiController
Hi Everyone,
I'm using Umbraco Version 7.2.2 and I'm trying to create a Controller class inhering from UmbracoApiController to retrieve published contents from Umbraco. I'm getting 2 problems
When retrieving published contents from RTE and there's macro interested into then found the exception "Cannot render a macro when there is no current PublishedContentRequest." I've read too many thread with same error but unable to find any solution. Some people said that in Umbraco V7.2 there'll be option to insert or create PublishedContentRequest instance. Someone plesae guide me to do this?
Secondly, I want a machnism to pass my paramter with PublishedContentRequest class to set the macro paramter. e.g. there's a paramter for macro parital view name id and I want to pass this value so that appropriate patial view(s) use this parameter value by accessing Model.MacroParameters["id"]. How can I achieve this?
It's almost a week to post this query on umbraco forum but unable to find any reply ;(
Now spending time to see several solutions and workarounds to this I'm finally moving toward creating a Contrller inherted from SurfaceController and there will a [HttpGet] method named GetContents(). Now moving towards SurfaceController provides me facility to instantiate PublishContentRequest instance by using ActionAtribute (inherit this attribute from EnsurePublishedContentRequestAttribute class.
Steps will be as follows
Make call to main method GetContents() (with parameters if any).
Get Contents from Umbraco UmbracoContext.ContentCache.GetById(contentId)
Check if UmbracoContext.PublishedContentRequest == null. if yes, use return RedirectToAction("CreatePublishedContentRequest", new { parameter1 });
CreatePublishedContentRequest method will be decoraded with Action attributed inertied from EnsurePublishedContentRequestAttribute class
override ConfigurePublishedContentRequest method of ActionAttribute and return back to old method call return RedirectToAction("GetContents", new { parameter1 });
Now used PublishedContentRequest istance (use session to save PublishedContentRequest istance created through ConfigurePublishedContentRequest metod) and assign it to UmbracoContext.PublishedContentRequest
I want to avoid making Redirect call to 2nd action (back and forth). Either there's some solution to skip this overhead? Like if I'm using same attribute to main calling method GetContetns it is not working (not invoked).
Any help in this regard will be highly appreciable.
Problem retrieving published contents using UmbracoApiController
Hi Everyone,
I'm using Umbraco Version 7.2.2 and I'm trying to create a Controller class inhering from UmbracoApiController to retrieve published contents from Umbraco. I'm getting 2 problems
Regards,
/Rizwan
It's almost a week to post this query on umbraco forum but unable to find any reply ;(
Now spending time to see several solutions and workarounds to this I'm finally moving toward creating a Contrller inherted from SurfaceController and there will a [HttpGet] method named GetContents(). Now moving towards SurfaceController provides me facility to instantiate PublishContentRequest instance by using ActionAtribute (inherit this attribute from EnsurePublishedContentRequestAttribute class.
Steps will be as follows
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/57240-UmbracoApiController-accessing-RTE-with-Macro-Error
Now I've some questions using this technique
I want to avoid making Redirect call to 2nd action (back and forth). Either there's some solution to skip this overhead? Like if I'm using same attribute to main calling method GetContetns it is not working (not invoked).
Any help in this regard will be highly appreciable.
/Rizwan
is working on a reply...