Views: 1704
Number of votes: 3
Average rating:

Get rid of EPiServer Commerce Migrate redirect loop

Phew! Take 2 hours to get rids of the infinitive loop from EPiServer ECommerce after upgrade from 9.2 to 12.17!

You can Google search with: episerver commerce migration loop

Then some guys below appear:



Some good instructions but does not work for my case: MigrateRedirect -> <RequireLogin> -> Owin -> MigrateRedirect -> <RequireLogin> -> ...

You can see more in those class:




Okay, so how can we resolve this? Some angeles below will help:

1.  // EPiServer.Commerce.Internal.Migration.MigrationManager

public virtual void MigrateAsync()

2. IoC with StructureMap and Interceptors holy light

internal class ContainerInitialization : IConfigurableModule, IInitializableModule


public void ConfigureContainer(ServiceConfigurationContext context)
    context.ConfigurationComplete += (o, e) =>
                e.Services.Intercept<MigrationManager>((locator, defaultMigrationManager) =>
                    new MigrationManagerInterceptor(defaultMigrationManager
                            , locator.GetInstance<MigrationStore>()
                            , locator.GetInstance<MigrateActionUrlResolver>()));

and last one:

public class MigrationManagerInterceptor : MigrationManager
        private MigrationManager _defaultMigrationManager;

        public MigrationManagerInterceptor(
            MigrationManager defaultMigrationManager
            , MigrationStore migrationStore
            , MigrateActionUrlResolver migrateActionUrlResolver)
            : base(migrationStore, migrateActionUrlResolver)
            _defaultMigrationManager = defaultMigrationManager;

        public override void RedirectToMigrationView()

Good bye redirect loop! Cheer!

// Ha Bui

Oct 01, 2019

( By GOSSO, 10/1/2019 7:37:02 AM)

Thank you for sharing, ive been struggling with this for years! 

Your solution is probably the best in history... 

My work arounds was "Log in as webadmin" before you release - not always possible

Or change in Appsetting: AutoMigrateEPiServer set to true use to work - but i know, not always applicable

Ha Bui
( By Ha Bui, 10/2/2019 8:00:46 AM)

Thank @GOSSO for your very constructive comment! I also tried some solutions as your but issue still there (sometime it works, weird)

Thank @Quan for your recap / overview solution! I also agree with you about documentation that should be better because of upgrading is very high risky, if we have not then how can motivate partner / customer upgrade to newer version?

// Ha Bui

Please login to comment.