Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Commerce Manager upgrade to 11.4, value cannot be null on initialization using EPiServer.Cms.UI.AspNetIdentity

Vote:
 

Hi!

We upgraded Commerce to 11.4 and implemented EPiServer.Cms.UI.AspNetIdentity on the login page.

That gave us this exception:

[ArgumentNullException: Värde får inte vara null.
Parameternamn: virtualPath]
   EPiServer.Shell.ShellInitialization.WaitForInitializeModules() +153
   EPiServer.Shell.<>c__DisplayClass11_0.b__1(Object sender, EventArgs args) +17

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +128
   System.Delegate.DynamicInvokeImpl(Object[] args) +153
   EPiServer.Framework.Initialization.InitializationEngine.OnInitComplete() +241
   EPiServer.Framework.Initialization.InitializationEngine.ExecuteTransition(Boolean continueTransitions) +214
   EPiServer.Framework.Initialization.InitializationModule.EngineExecute(HostType hostType, Action`1 engineAction) +402
   EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +227
   EPiServer.Global..ctor() +103
   ASP.global_asax..ctor() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\8e4eadf3\4a4b2790\App_global.asax.9erted9t.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +197
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +105
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1484
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +289
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +27
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +79
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +294
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +333

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +124
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +700

I then fond this article:

https://episerver.zendesk.com/hc/en-us/articles/115004119606-Shell-Initialization-Errors-in-Commerce-Manager-When-Updated-to-v10

Telling me to remove EPiServer.Cms.UI.AspNetIdentity.dll. If I remove it, my project wont compile. If I remove these:
EPiServer.Cms.Shell.UI.dll
EPiServer.UI.dll
EPiServer.Shell.UI.dll
EPiServer.Shell.dll

It fails because EPiServer.Cms.UI.AspNetIdentity.dll requires them.

Maybe you cant use EPiServer.Cms.UI.AspNetIdentity.dll in the Commerce Manager?

The Login.aspx.cs looks like this:

using Designonline.Shared.Identity;
using EPiServer.Cms.UI.AspNetIdentity;
using Microsoft.AspNet.Identity.Owin;
using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Designonline.Manager
{
    /// 
    /// This is a custom code behind for the login page for CommerceManager
    /// to get OWIN authentication.
    /// 
    /// 
    /// We replace the original one as a build step when building this project. 
    /// See the AfterBuild msbuild target in this files project file for details 
    /// on how that is done.
    /// 
    public partial class Login : Page
    {
        private const string UserLoginFailureMessage = "Login failed. Please try again.";

        private ApplicationSignInManager _signInManager;

        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Header.DataBind();

            _signInManager = Request.GetOwinContext().Get>();
            LoginCtrl.Authenticate += LoginCtrl_Authenticate;

            if (IsPostBack)
            {
                return;
            }
            LoginCtrl.FindControl("ApplicationRow").Visible = Mediachase.Commerce.Core.AppContext.Current.GetApplicationDto().Application.Count != 1;
            LoginCtrl.Focus();
        }

        protected void LoginCtrl_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var userName = ((TextBox)LoginCtrl.FindControl("UserName")).Text;
            var password = ((TextBox)LoginCtrl.FindControl("Password")).Text;
            var remember = ((CheckBox)LoginCtrl.FindControl("RememberMe")).Checked;

            var validated = _signInManager.PasswordSignInAsync(userName, password, remember, false).Result == SignInStatus.Success;
            if (validated)
            {
                HandleLoginSuccess(userName, remember);
            }
            else
            {
                HandleLoginFailure(UserLoginFailureMessage);
            }
        }

        private void HandleLoginSuccess(string userName, bool remember)
        {
            string url = FormsAuthentication.GetRedirectUrl(userName, remember);
            if (url.Equals(FormsAuthentication.DefaultUrl, StringComparison.OrdinalIgnoreCase) ||
                url.Contains(".axd") ||
                url.Contains("/Apps/Core/Controls/Uploader/"))
            {
                url = "~/Apps/Shell/Pages/default.aspx";
            }

            Response.Redirect(url);
        }

        private void HandleLoginFailure(string pageMessage)
        {
            LoginCtrl.FailureText = pageMessage;
        }
    }
}

Thanks!

/Kristoffer

#185272
Nov 14, 2017 8:49
Vote:
 

The error was because the web.config was corrupt. Comparing web.config with QuickSilver 11.2.6 solved the problems.

/Kristoffer

#185281
Edited, Nov 14, 2017 10:34
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.