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 forums.ablecommerce.com. Please use your AbleCommerce username and password to Login. New Registrations are disabled.



Go to last post Go to first unread
Joe Payne @ AbleMods LLC  
#1 Posted : Thursday, October 14, 2021 6:55:13 AM(UTC)
Joe Payne @ AbleMods LLC

Rank: Advanced Member

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

Thanks: 83 times
Was thanked: 14 time(s) in 13 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:


        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:

                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.

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

Rank: Advanced Member

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

Thanks: 2 times
Was thanked: 85 time(s) in 84 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 Payne @ AbleMods LLC 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.