logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne2  
#1 Posted : Thursday, October 14, 2021 6:55:13 AM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
We've noticed several error log messages throwing an exception when the url is formatted as the default MVC route i.e. /product/index/711?categoryid=16

The exception is in /controllers/productcontroller.cs in this child action:

Code:

        [ChildActionOnly]
        public ActionResult PageTemplate(int id)
        {
            var product = _productRepo.Load(id);
            if (product == null)
                return HttpNotFound();

            PageData model = CurrentRequestData.PageData;
            var innerTemplate = model.InnerTemplate;
            var outerTemplate = model.OuterTemplate;
            
            if (outerTemplate != null)
            {
                return View(innerTemplate.Layout.FilePath, "OuterTemplate", model);
            }

            return View(innerTemplate.Layout.FilePath, model);
        }


The problem is model is coming back null.

The reason it's null is when the LayoutDataAttribute[] OnActionExecuting() (in /CommerceBuilder.Web/MVC/) fires on the request, it tests for the action name using Camel case here:
Code:

                if (_controllerNames.Contains(controllerName) && actionName == "Index")


Note how actionName is 'Index', not 'index'. And without the .ToLowerInvariant() applied, this test fails and CurrentRequestData.PageData never gets populated.

This causes the model in the child action to be null as well, which isn't tested for and the page exception is thrown. And the product page never renders.

We don't know where these default mvc route hits are coming from yet. We don't believe it's internal but we're not sure.

My concern: Shouldn't the LayoutDataAttribute be applying .ToLowerInvariant() to the action name so the test for an 'Index' action never fails?

I can't decide if this should counted as a bug, as a stability improvement or simply a fail-safe against unexpected urls.

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

shaharyar  
#2 Posted : Thursday, October 14, 2021 11:25:15 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 703

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
Hi Joe,

Thanks for pointing this out. I'll open a discussion on this.
thanks 1 user thanked shaharyar for this useful post.
Joe Payne2 on 10/14/2021(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.