Route to a Local Block Controller with action for AJAX request

Vote:
 

Does anyone know best way to do an AJAX Post /Get with in a local page block?

E.g. I have a local block on home page, which has its own controller /view etc., but I want to call a separate action result using jQuery Ajax but want the current page and current block content available.  I can get to controller by registering a custom route in global but do not have the current page / block content available.

#66541
Mar 04, 2013 15:32
Vote:
 

There may be other options but from the top of my head I can only think of one "simple" solution as the local block isn't an entity in it self but a part of the page  - add the action to the page's controller.

 

If the block can also be used a shared block, meaning you want the action in the block's controller you could implement the action in the page's controller to just delegate to the block controller's action.

 

#66564
Mar 05, 2013 10:20
Vote:
 

Thanks, as I am using a block controller and my own view model to extend block properties I have passed page content guid to view and used an html 5 data tag for ajax request back to action and load the page info again, this works but probably not the best solution

e.g.

var pageRouteHelper = ServiceLocator.Current.GetInstance<PageRouteHelper>();
if (pageRouteHelper.Page != null)
{
PageContentGuid = pageRouteHelper.Page.ContentGuid;
}

 

 

#66577
Mar 05, 2013 15:31
Vote:
 

Same problem here, I want to filter a block with ajax, any suggestions other than adding an action to the page controller? 

#82578
Mar 14, 2014 16:59
Vote:
 

Set up Web API and use that instead for AJAX requests?

#82582
Mar 14, 2014 17:45
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.