This project is read-only.

Access page url from admin panel

Topics: Customizing Orchard, Writing modules
Mar 24, 2011 at 4:31 PM

Hello How to get page url from admin panel where the page is edited


the page ID is 49 in admin panel URL


the 'real' page url is


how to get this url from Driver which is called from admin panel

 public class QRCodePartDriver : ContentPartDriver        {            private readonly IHttpContextAccessor _httpContextAccessor;

 public QRCodePartDriver(INotifier notifier, IHttpContextAccessor httpContextAccessor, INavigationManager nav, RouteCollection routeCollection)            {                
     _httpContextAccessor = httpContextAccessor;    
            _nav = nav;  
              _routeCollection = routeCollection;        



returns http://localhost:30320/OrchardLocal/Admin/Contents/Edit/49

i need to get length of http://localhost:30320/OrchardLocal/tools/body-mass-index

from http://localhost:30320/OrchardLocal/Admin/Contents/Edit/49

Mar 25, 2011 at 1:15 AM

You can get the URL for a content item from Url.ItemDisplayUrl that is provided by Orchard.Mvc.Html.ContentItemExtensions.

Mar 25, 2011 at 10:13 AM

Thank you, the complete code looks like this

 protected override DriverResult Editor(
                QRCodePart part, dynamic shapeHelper)

                string url = ContentItemExtensions.ItemDisplayUrl(new UrlHelper(new RequestContext(
                  new HttpContextWrapper(HttpContext.Current),
                  new RouteData()), RouteTable.Routes), part);

Mar 25, 2011 at 12:50 PM

Thanks, I was looking for this.

This should be available as a utility method somewhere in Orchard.Routable so you can get an item URL easily without being inside a View (as the Url.ItemDisplayUrl requires).