November Happy Hour will be moved to Thursday December 5th.

Blob provider URL root

Vote:
 

Hi all,

I have migrated to CMS 7.5 and used VPP migration tool to migrate files. Now. I can see that file URLs have /globalassts/ at the begining. Does anybody know how I can change this and instead of serving files via /globalassets/Global/* serve files via /Global/* ?

#112890
Nov 06, 2014 22:48
Vote:
 

If you do not check the checkbox "Create a subfolder for each Virtual Path Provider" in the migration tool then your resources will get a path like: /globalassets/*. 

Then you can register a new route with a different name than "globalassets" like:

routes.MapAssetRoutes(
name: "CustomMedia",
url: MediaStaticSegmentPlaceHolder + "/{node}/{partial}/{action}",
defaults: new { action = "index" },
staticSegmentPlaceHolder: RouteCollectionExtensions.MediaStaticSegmentPlaceHolder,
globalReplacement: "Global",
siteReplacement: RouteCollectionExtensions.SiteAssetStaticSegment);

you need to add your route before the default one, e.g. in an event handler to Global.RoutesRegistrating.

Then optionally (for performance reasons it is unnessecary to have extra routes) you can remove the original ContentRoute named "Media". This can be done e.g. in an event handler to Global.RoutesRegistered.

#112900
Nov 07, 2014 10:16
Vote:
 

When I didn't check that box it put all the files in one main folder and the whole structure we had in CMS 7 (including block folders) were gone

#112901
Nov 07, 2014 10:42
Vote:
 

Yes, if you do not check in the check box the vpp structure will be merged in to the existing structure (It should not delete the old structure).

Is the problem that you really want the url to look like /Global/* or that you want old urls (like e.g. in bookmarks) like /Global/* to still work? If the latter is the case then you could set up a simple redirect rule in IIS from /Global/* to /globalassets/Global/*.

#112902
Nov 07, 2014 10:48
Vote:
 

I would rather if /globalassets/ weren't added to the beginning of the URL. But if there is no way to remove that I will have to put a redirect as you say.

#112903
Nov 07, 2014 10:51
Vote:
 

As I said above you can change "globalasset" to something else like "Global". But if you then check the checkbox in migration tool you will get urls like "Global/Global/*" which I guess is not what you are after... 

#112904
Nov 07, 2014 10:58
Vote:
 

Oh thanks. That is better.

#112905
Nov 07, 2014 11:00
Vote:
 

When I think of it, you could probably do as I said above to register an own route but instead register it as:

routes.MapAssetRoutes(
name: "CustomMedia",
url: "/{node}/{partial}/{action}",
defaults: new { action = "index" });

Then it should not add "globalassets" before in the url. However you will get a bit of a perfromance penalty since it cant decide immediately if the route matches or not (like it can with a static segment in the beginning).

#112907
Nov 07, 2014 11:01
Vote:
 

I put the following code in Global.asax

        routes.MapAssetRoutes(
name: "CustomMedia",
url: RouteCollectionExtensions.MediaStaticSegmentPlaceHolder + "/{node}/{partial}/{action}",
defaults: new { action = "index" },
staticSegmentPlaceHolder: RouteCollectionExtensions.MediaStaticSegmentPlaceHolder,
globalReplacement: "Global",
siteReplacement: RouteCollectionExtensions.SiteAssetStaticSegment);

but it still adds the globalassets to the beginning of asset urls :(

#112910
Nov 07, 2014 11:56
Vote:
 

You need to add it before the call to base.RegisterRoutes

#112911
Nov 07, 2014 11:57
Vote:
 

Ok thanks. Sorry I missed the line which you mentioned that. Do I need to do anything else in order to serve the content? At the moment I have URLs like /Global/something/something/image.png but I am getting 404 .

#112912
Nov 07, 2014 12:04
Vote:
 

Sorry, not a 404 but an internal error.

#112913
Nov 07, 2014 12:05
Vote:
 

Got it working. Problem at my end. Thank you very much.

#112914
Nov 07, 2014 12:06
Vote:
 

The problem is that this has caused issues with the home page. The home page loads the first time but when I refresh I get 404.

2014-11-07 12:47:39,647 [43] ERROR EPiServer.Global: 1.2.5 Unhandled exception in ASP.NETSystem.Web.HttpException (0x80004005): Not Found   at EPiServer.Web.Routing.MultiplexingRouteHandler.GetPageRouteHandler(Object routedData, String path, String language, Boolean return404)   at EPiServer.Web.Routing.MultiplexingRouteHandler.GetRouteHandlerOrRedirect(RequestContext requestContext, Object routedData, Boolean throw404IfNotFound)   at EPiServer.Web.Routing.MultiplexingRouteHandler.GetRouteHandler(RequestContext requestContext)   at EPiServer.Web.Routing.MultiplexingRouteHandler.GetHttpHandler(RequestContext requestContext)   at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context)   at System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e)   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

#112920
Nov 07, 2014 13:54
Vote:
 

I see, the problem is that your new route now takes care of the request http://site.com/ since the route will get a request to route path "/" which it will do and return GlobalAssetRoot, and hence that is a folder without a template will the routehandler return a 404..

You need to get your route registered in the same place as the ordinary media router. You could have some code like:

        protected override void RegisterRoutes(System.Web.Routing.RouteCollection routes)
        {
            base.RegisterRoutes(routes);
            
            //get index for original media route
            var mediaRouterIndex = GetIndexForRoute("Media", routes);

            //register new route, will be added last
            routes.MapAssetRoutes(
                name: "CustomMedia",
                url: "/{node}/{partial}/{action}",
                defaults: new { action = "index" });

            var newRoute = GetIndexForRoute("CustomMedia", routes);
            //remove route from last in list
            RouteTable.Routes.Remove(newRoute);
            //insert before existing media route
            RouteTable.Routes.Insert(mediaRouterIndex , newRoute);
        }

        static int GetIndexForRoute(string name, RouteCollection routes)
        {
            for (int i = 0; i < routes; i++)
            {
                var contentRoute = routes[i] as ContentRoute;
                if (contentRoute != null && contentRoute.Name.Equals(name))
                {
                    return i;
                }
            }
            return -1;
        }
#112921
Edited, Nov 07, 2014 14:04
Vote:
 

Unfortunately that didn't work either. when I remove Media route then another route kicks in and add something else in the beginning such as siteassets or syssite .

#112934
Nov 07, 2014 16:39
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.