I have a block controller with an action that is mapped to a custom route:
public class MyBlockController : BlockController
public override ActionResult Index(MyBlock currentBlock)
public string CustomRouteMethod(string parameter1)
// Is it possible to get an instance of MyBlock here? Since this method should be
// invoked with AJAX, we can't post any models.
Is this possible?
I've already tried the following without success:
That's not working out of the box, as next (you Ajax call to the server) request is out of context and has "lost connection" to original block.
Another alternative (not so easy) - you would need to "restore" routing data for EPiServer to understand within which block Ajax call is happening. This is not so easy due to manipulation of RouteData objects and state to "convience" EPiServer to pick up correct block type / instance.
I guessed as much... What I ended up doing was to render the block ID as a data attribute in the markup, and sending it as a parameter in the Ajax call. In the CustomRouteMethod() I then fetched the block using IContentRepository.