November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
In theory from a javascript call (ajax), block is out of context. Think MVC Areas or a web api to fulfil your service requests.
Regards
/K
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.
One of the possible solutions (if your project's security policy allows that) you could read those properties from the block while rendering the markup for the inital request's response. Then add those values to the markup, pass them over to Javascript and use them in next Ajax call as parameters.
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.
I have a block controller with an action that is mapped to a custom route:
In this action I want to access som block properties, but I can't figure out how to obtain an instance of the current block. Since the action should be invoked from JavaScript, the block can't be passed in as a parameter - instead it has to be resolved based on the current context somehow.
Is this possible?
I've already tried the following without success: