London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Issue with UrlResolver.GetUrl

Vote:
 

Hallo.

I have a problems with UrlResolver.GetUrl(ContentReference contentLink, string language). When i call this method from UI, I get correct url for item of menu. When i call this method from edit mode, i get url with element of url of edit mode for item of menu.

Version: Assembly EPiServer.dll, v7.6.5.0

Example(get url for item of menu):

...

var urlResolver = ServiceLocator.Current.GetInstance();

var url = urlResolver.GetUrl(contentReference, language);

...

Where contentReference={1073741825__CatalogContent} and language="sv".

When call this code from edit mode: url = "/episerver/CMS/Content/,,39810/catalog/verktyg-och-maskiner,,1073741825__CatalogContent/?epieditmode=True"

When call this code from UI: url = "/catalog/verktyg-och-maskiner/?overview=True"

Is it bug? Or do I do something wrong? Are any ideas? Please, help.

Best Regards,

Dzmitry Salauyou

#117195
Feb 13, 2015 11:18
Vote:
 

I had a similar problem, ended up using @Url.ContentUrl(contentReference) instead (System.Web.Mvc.WebViewPage.Url). Made a wrapper for it for using in the controllers.

//Mathias

#117201
Edited, Feb 13, 2015 11:43
Vote:
 

Mathias Kunto, Thank you.

But, this method doesn't work. I get the similar result, if i use urlResolver.GetUrl in edit mode.

Best Regards,

Dzmitry Salauyou

#117253
Feb 16, 2015 9:11
Vote:
 

If I use
var url =urlResolver.GetUrl(contentReference, language, new VirtualPathArguments() {RouteValues = routeValueDictionary})

where routeValueDictionary = new RouteValueDictionary {{"overview", true}},

I get url = "/episerver/CMS/Content/,,39810/catalog/verktyg-och-maskiner,,1073741825__CatalogContent/?epieditmode=True&overview=True"

Are any ideas?

Best Regards,

Dzmitry Salauyou

#117255
Feb 16, 2015 10:16
* 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.