How to get page url for edit mode?

Vote:
 

How to get page url for edit mode?

#76382
Oct 23, 2013 16:01
Vote:
 

http://mysite.com/Admin/CMS/Edit/Default.aspx

#76383
Oct 23, 2013 16:12
Vote:
 

I use

  var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
  var listingPageUrl = urlResolver.GetVirtualPath(subPage.ParentLink, language);

and sometimes the PageEditing.GetPageIsInEditMode(httpContext) returns false

So I would like to know, how to get the page correct address in edit mode via url helper or somehow?

#76389
Oct 23, 2013 17:21
Vote:
 

Hello,

There is a static helper method PageEdititng.GetEditUrl that accepts a ContentReference and returns URL in edit mode.

#76411
Oct 24, 2013 9:26
Vote:
 

Hello,

Thank you for help.

Yes, it returns the edit url, but I need a little bit different page link in edit mode.

If you look at the generated site menu in edit mode, the links are not like 

http://localhost:85/episerver/cms/#context=epi.cms.contentdata:///18

they are like

http://localhost:85/EPiServer/CMS/Content/EP11111,,11/?id=11&epieditmode=true

So, is it possible to get such view for link?

 

 

 

#76415
Oct 24, 2013 9:48
Vote:
 

This link you can get by using one of the extension methods from EPiServer.Web.Routing.RouteCollectionExtensions class:

RouteTable.Routes.GetVirtualPath(subPage.ParentLink, language, true, true).GetUrl()

    

#76420
Oct 24, 2013 10:27
Vote:
 

Thank you!

 

 

#76430
Oct 24, 2013 11:51
Vote:
 

Sorry removed the post but the question was: how to get the same as above since it is obsolete.

Thanks

#119601
Edited, Mar 31, 2015 12:10
Vote:
 

Hello,

Probably, something like this:

var virtualPathArguments = new VirtualPathArguments { ContextMode = ContextMode.Edit};
var url = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(currentPage.PageLink, "en", virtualPathArguments);
#119603
Mar 31, 2015 12:30
Vote:
 

Sorry removed the post but the question was: how to get the same as above since it is obsolete.

Thanks

#119604
Mar 31, 2015 12:41
Vote:
 

This solution of Sergii Vorushylo works like a charm (in CMS10 as well)

EPiServer.Editor.PageEditing.GetEditUrl(contentLink);



#171816
Nov 18, 2016 3:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.