Try our conversational search powered by Generative AI!

routing issue after upgrade to CMS 9.10.2

Vote:
 

Hi,


In result of upgrade from CMS 9.6.1 to 9.10.2. A Particular Page is giving following issue.


The routed data is of type 'XYZ.Models.Pages.ArticlePage' and the binding context data 'currentPage' is of type 'XYZ.Models.Pages.ArticlePage', neither of which matches the requested type 'XYZ.Models.Pages.BlogArticlePage'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: EPiServer.Core.TypeMismatchException: The routed data is of type 'XYZ.Models.Pages.ArticlePage' and the binding context data 'currentPage' is of type 'XYZ.Models.Pages.ArticlePage', neither of which matches the requested type 'XYZ.Models.Pages.BlogArticlePage'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[TypeMismatchException: The routed data is of type 'XYZ.Models.Pages.ArticlePage' and the binding context data 'currentPage' is of type 'XYZ.Models.Pages.ArticlePage', neither of which matches the requested type 'XYZ.Models.Pages.BlogArticlePage'.]

EPiServer.Web.Mvc.ContentDataModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +985
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +460

where

[ContentType(DisplayName = "Blog Article", GUID = "489F9E24-A883-47C2-A11D-1314EBD0D14B"
BlogArticlePage : ABase
and
[ContentType(DisplayName = "Article Page", GUID = "5ca2415c-1a81-40cb-91e5-d182c626a308"
ArticlePage : ABase

From

The routed data is of type 'XYZ.Models.Pages.ArticlePage' and the binding context data 'currentPage' is of type 'XYZ.Models.Pages.ArticlePage', neither of which matches the requested type 'XYZ.Models.Pages.BlogArticlePage'.

BlogArticlePage has been picked wrongly

Any Idea?

Reverting changes back to 9.6.1 resolves issue.

#150352
Jun 16, 2016 15:38
Vote:
 

May this will help to investigate or understand the issue.

We have following controllers

public class BlogArticlePageController : PageController<ABase>
{
public ActionResult Index(BlogArticlePage currentPage)
{}
}

public class ArticlePageController : PageController<ABase>
{
public ActionResult Index(ArticlePage currentPage)
{}
}

where page types are 

BlogArticlePage : ABase

ArticlePage : ABase

Probably When we are creating an Article page in CMS, Route handler is resolving wrong controller i.e. BlogArticlePageController rather ArticlePageController 

This structure was absolutly working fine till 9.6.1

#150410
Jun 17, 2016 10:22
Vote:
 

The action methods are not part of selecting controllers, you need to change PageController<ABase> to PageController<ArticlePage> for the page that renders ArticlePage. Since the 2 controllers are identical and renders the same type (ABase) there is no guarantee which will be picked since they are inseparable for the template engine. I agree that it was weird that it worked before and now stopped working.

#150411
Jun 17, 2016 10:42
Vote:
 

We have already tested that and it works with that change. I am wondering its a very general architecture. Its a breaking change for us and not an easy fix. Is there any work arround or magical routing mapping to make it working? It will be helpful if you could briefly explain that why it was working before. It will help our client to understand the issue in a better way.

Regards

/K

#150412
Jun 17, 2016 10:50
Vote:
 

You can use ITemplateResolverEvents and change the selected template based on your requirement, maybe that is a way forward.

#150414
Jun 17, 2016 11:26
Vote:
 

Thanks Per, We will probably go for changing PageController implementation.

Regards
/K

#150478
Jun 20, 2016 13:18
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.