AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
9.0.4 Concerns with default MVC routing
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.
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
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.
|
1 user thanked shaharyar for this useful post.
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
9.0.4 Concerns with default MVC routing
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.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close