Correct link is http://world.episerver.com/Documentation/Class-library/?documentId=cms/7/6a2d22e8-b20c-9cd8-86d5-fc0259c2029b
You could use it like this:
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var references = contentRepository.GetReferencesToContent(someReference, false);
Ok, I have tried this out:
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var references = contentRepository.GetReferencesToContent(((IContent) Model).ContentLink, false);
But that gives me references to all content that references this block instance.
But is it somehow possible for a block to find out (in its cshtml file for instance) in what page it is rendered at that moment?
The thing i would like to achieve is for my block to find out under what SiteRoot (Start Page) it is rendered so it can get some properties from that SiteRoot. One solution is to add a property to my block that holds a PageReference to the SiteRoot but if I would like to use one instance of my block on several different SiteRoots then it will fail..
Any suggestions?
Ah, check out this forum topic on how to get the current page:
http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=75674&
Thanks! It works exactly as I want it:
var pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator
.Current.GetInstance<EPiServer.Web.Routing.PageRouteHelper>();
var currentPage = pageRouteHelper.Page;
I know a block can belong to a lot of different pages but could it be possible to somehow, during the rendering of the view, use this statement to get the context in which it is in or some other method.
When I use the above statement I get SysRoot content link so it obviously does not work as I want it to...
Any suggestions?