Quantcast
Channel: Using Optimizely Platforms
Viewing all articles
Browse latest Browse all 8020

Browse to a block.

$
0
0

EPiServer 11.12.0

What do I need to set up to be able to browse to a block?

http://localhost/{path-to-block}/
http://localhost/en/{path-to-block}/
http://localhost/{path-to-block}/PreferredAction
http://localhost/en/{path-to-block}/PreferredAction

Somehow like you can browse to a file under the content-assets hierarchy. Because the blocks are, like files, saved under that hierarchy.

I can hit the action by the url like this:
http://localhost/MyBlock/Index

But if a try http://localhost/en/MyBlock/Index I get 404

Do I need to set up an extra ContentRoute?
Do I need to add a site-specific block-conroller that implements IRoutable?

I want this because I want to refresh parts of a block with ajax on a page. And instead of setting up an ApiController and returning json and then fix the html I would like to have actions on my BlockController that returns partial-views with just the html I want to replace on the client-side.

If I use UrlResolver.Current.GetUrl() I get an url for a file-content-link but I get null for a block-content-link:
File: UrlResolver.Current.GetUrl(new ContentReference(61)) => /globalassets/alloy-meet/alloymeet.png
Block: UrlResolver.Current.GetUrl(new ContentReference(47)) => null

Hope someone can help me.

/Hans


Viewing all articles
Browse latest Browse all 8020

Trending Articles