HotcakesCommerce / hotcakes-commerce-core

The core of the e-commerce part of the overall solution. This is an ecommerce shopping cart solution built on top of the DNN (DotNetNuke) CMS. Anyone can do commerce online now!
https://mmmcommerce.com
MIT License
68 stars 55 forks source link

CheckoutController -> LoadCheckoutModel: Redirect not working if CurrentCart == null #354

Open Navilois opened 3 years ago

Navilois commented 3 years ago

Describe the bug

Checkout crashes with an exception if CurrentCart == null.

Software Versions

To Reproduce

Steps to reproduce the behavior:

  1. Go to the checkout page in a clean browser window, e.g. https://www.sierzega.com/en-us/products/checkout
  2. See error

Expected behavior

The visitor should be redirected to the shopping cart - https://github.com/HotcakesCommerce/hotcakes-commerce-core/blob/eeaf48274e1666a3864f2ecfe5412fb3c8fc1056/Website/DesktopModules/Hotcakes/Core/Controllers/CheckoutController.cs#L571

Actual behavior

The Redirect doesn't work (no error) and the code continues to execute causing to crash on null references due to the empty CheckoutViewModel

Screenshots

If applicable, add screenshots to help explain your problem.

Error log

Note: Debug DLL's Please replace the current extension DLL's with the debug DLL's (if these are available with the release) and reproduce the error with the debug DLL's before pasting the error log.

Paste the error log that is related to this issue. 2021-04-06 13:35:44.362+02:00 [Vertrieb5][D:5][T:113][ERROR] DotNetNuke.Services.Exceptions.Exceptions - FriendlyMessage="Error: Checkout is currently unavailable." ctrl="ASP.desktopmodules_hotcakes_checkout_checkoutview_ascx" exc="System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. ---> System.NullReferenceException: Object reference not set to an instance of an object. at ASP._Page_Portalsdefault_HotcakesViews_MyViewSet_Views_CheckoutLogin_cshtml.Execute() in d:\websites\sierzega.com\Portals_default\HotcakesViews\MyViewSet\Views\Checkout_Login.cshtml:line 72 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) at ASP._Page_Portalsdefault_HotcakesViews_MyViewSet_Views_Checkout_Index_cshtml.Execute() in d:\websites\sierzega.com\Portals_default\HotcakesViews\MyViewSet\Views\Checkout\Index.cshtml:line 43 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>cDisplayClass21.b1e(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) at System.Web.Mvc.Controller.b1d(IAsyncResult asyncResult, ExecuteCoreState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.b5(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>cDisplayClass4.b3() at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func) at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) at System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) at Hotcakes.Commerce.Dnn.Mvc.MvcRenderingEngine.Render(String controllerName, String actionName, String viewName, Object routeValues) in D:\dev\hotcakes-commerce-nav-fork\Libraries\Hotcakes.Commerce.Dnn\Mvc\MvcRenderingEngine.cs:line 90 at Hotcakes.Modules.Checkout.CheckoutView.RenderView() in D:__dev\hotcakes-commerce-nav-fork\Website\DesktopModules\Hotcakes\Checkout\CheckoutView.ascx.cs:line 53 at Hotcakes.Commerce.Dnn.Web.HotcakesModuleBase.OnLoad(EventArgs e) in D:__dev\hotcakes-commerce-nav-fork\Libraries\Hotcakes.Commerce.Dnn\Web\HotcakesModuleBase.cs:line 116"

Additional context

Add any other context about the problem here.

I've debugged the entire thing extensively - honestly, I have no idea why it doesn't work. I have followed the path to https://github.com/HotcakesCommerce/hotcakes-commerce-core/blob/eeaf48274e1666a3864f2ecfe5412fb3c8fc1056/Libraries/Hotcakes.Commerce/Extensions/HccRedirectResult.cs#L38

Seems to be all good except that it doesn't redirect? Am I missing something?

Navilois commented 3 years ago

Found the problem: PR #307 changed the Redirect from HttpResponseBase Controller to BaseAppController

I don't know why exactly, but the BaseAppController doesn't pull off the Redirect. It works with the HttpResponseBase Controller, PR reverting those changes coming soon