Upgrade from 7 to 8 - Classical links

Vote:
 

Hi,

I'm trying to upgrade our project from CMS version 7 to 8.

I've seen that you have removed the "Classical links" from the current API.

Is there anyway to get the classical links in version 8? this is very important, we have extensive use of the classical links,

Please advice,

Z.

#148612
May 18, 2016 12:27
Vote:
 

Hi, Ziv,

Check Johan's blogpost here:

http://world.episerver.com/blogs/Johan-Bjornfot/Dates1/2013/12/Routing-changes-in-75/

There is a section about how to register a route that handles classical links.

I am not sure if any of the breaking changes would affect this, but in any case, you should be able to register a route yourself.

#148639
May 19, 2016 10:22
Vote:
 

Thank you for your input.

I've added the <ClassicalRoute> in RegisterRoute as shown, but I'm not sure how I am suppose to get the classical name. (I expect something like /.../HomePage.aspx,

Instead I get something like /link/asdlkjhjk32098a7sd.aspx or the friendly URL which is "/" for the homepage...

This is what I've tried: (several things combined)

  System.Web.Routing.RequestContext oHttpContextRoute = EPiServer.Web.Routing.RequestContextExtension.GetRequestContext(HttpContext.Current);
                    string path = EPiServer.Web.Routing.UrlResolver.Current.GetPermanent(oHttpContextRoute.HttpContext.Request.Path, false);
                   UrlBuilder url = new UrlBuilder(path);
                   EPiServer.Web.PermanentLinkMapStore.ToMapped(url);

                    //tried this too
                   //EPiServer.Web.PermanentLinkMapStore.ToPermanent(url);

                    if (url.Path.Contains(".aspx") && !url.Path.Contains("backoffice/"))
                    {
                        var contentReference = UrlResolver.Current.Route(new UrlBuilder(path));
                        var test1 = UrlResolver.Current.GetUrl(path);
                        var test2 = UrlResolver.Current.GetVirtualPath(contentReference.ContentLink);
                        if (true || !String.IsNullOrEmpty(url.QueryCollection["id"]) &&
                            url.QueryCollection["id"] != "0")
                        {
                            PageReference pr = new PageReference(contentReference.ContentLink.ID);


                            /*as seen for epi 7.19 (?)*/

                            var values = new RouteValueDictionary();
                            values[RoutingConstants.NodeKey] = new ContentReference(contentReference.ContentLink.ID);
                            var virtualPath = System.Web.Routing.RouteTable.Routes.GetVirtualPath(System.Web.HttpContext.Current.Request.RequestContext, values);
                            var routeName = (virtualPath.Route as ContentRoute).Name; //(this throws exception)

                            /**/

                            if (!PageReference.IsNullOrEmpty(pr))
                            {
                                PageData page = null;

                                if (DataFactory.Instance.TryGet<PageData>(pr, out page) && page != null)
                                {
                                    if (ListManager.PageIDList.Contains(page.PageTypeID))
                                    {
                                        var urlHelper = ServiceLocator.Current.GetInstance<UrlHelper>();
                                        var friendlyUrl = urlHelper.ContentUrl(page.LinkURL.ToString());
                                        var content = urlHelper.Content(page.LinkURL.ToString());
                                        var pageUrl = urlHelper.PageUrl(page.LinkURL);
                                        EPiServer.Web.PermanentContentLinkMap test = new EPiServer.Web.PermanentContentLinkMap(contentReference.ContentGuid, "aspx", url.Uri, contentReference as ContentReference, new PageMapSettings(url.Uri, ""));
                                        //jeere
                                        string newPath = friendlyUrl.Replace(".aspx", "_m.aspx");
                                        string query = oHttpContext.Request.QueryString.ToString();
                                        if (!String.IsNullOrEmpty(query))
                                        {
                                            newPath = newPath.Contains("?") ? newPath + "&" + query : newPath + "?" + query;
                                        }
                                        oHttpContext.RewritePath(newPath);
                                    }
                                }
                            }



#148644
May 19, 2016 11:46
* 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.