PAYING 50 EUR - Help me fix Umbraco.Web.Mvc.ModelBindingException
Anyone know what may be the issue? I am getting this error:
Umbraco.Web.Mvc.ModelBindingException: Cannot bind source content type [redacted].Web.ViewModels.PageNotFound to model type [redacted].Web.ViewModels.Subpage.
The error arises when trying to load a 404 error page of document type 'Errorpage'. I am new to Umbraco so I am not entirely sure how to decode the message, but googling suggests that it may be because of this line in /Views/Subpage.cshtml?
After spending so much time trying to fix this I am pretty desperate at this point so I am paying 50 eur if you can help me fix this (although transaction costs may be deducted from this if you're outside the EU)
Your issue here is that the code is trying to render a .cshtml page that is expecting a [redacted].Web.ViewModels.Subpage (coming from the @inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.Subpage>), however your code is sending a [redacted].Web.ViewModels.PageNotFound thus is cannot render the view due to a wrong model
Could you try changing @inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.Subpage> to @inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.PageNotFound>?
Thanks for the response. The thing that confuses me is that there is no template for pageNotFound, only for subpage.
This line is in the Subpage template @inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.Subpage>. The Subpage template is used successfully for some other pages so I I think if I change ViewModels.Subpage to ViewModels.PageNotFound it would break those.
Honestly, I am confused about where pageNotFound even gets @inherits Umbraco.Web.Mvc.UmbracoViewPage<Raido.Web.ViewModels.Subpage> from as in the I can't find pageNotFound document type I can't find any reference to Subpage...
BTW, I inherited this codebase and was thrown in the deep end as I never worked with Umbraco before so my apologies if I am not much help.
Yeah, if you would change that line while it is used in other places, it will break them.
The reference to the template could come from a few places. You could check the following:
Document type under the content app "Templates", but it sounds like you already check this one.
The content type under the content app "Info". There should be a dropdown under a header "Template". Sometimes it is shown empty while there is actually a template under it. Might be handy to republish just in case.
The pageNotFound could be set through a IContentLastChanceFinder. The template could also be set dynamically in this finder.
Maybe you have a plugin installed that influences this.
Best thing would probably be to either have the PageNotFound document type inherit from the Subpage so that you can use the same template. Or create a specific pageNotFound template and link it with that.
The content type under the content app "Info". There should be a dropdown under a header "Template". Sometimes it is shown empty while there is actually a template under it. Might be handy to republish just in case.
This was actually the case! There are no dropdown options but when I select open it open the Subpage template.
I am down for either solution but I get stuck here:
For the first solution, I'm in the PageNotFound document type but I don't know how to change it to inherit from the Subpage document type. Following this article I went into Compositions and I see an option to select /Layout/Reusable ribbons/reusable ribbons but no option for the Subpage document type which is /Layout/Reusable ribbons/Subpage
For the second solution, I created another template pageNotFound.cshtml but I can't select the error page to use this as the dropdown is empty.
For the first solution, you'll probably have to move the PageNotFound document type to be under the Subpage document type. Ofcourse, I don't know the complete structure of your Umbraco, so I would suggest trying to do the second solution first.
As for the second solution. Did you also add the new template to your document type here?
If it isn't added there, then it also won't show as one of the options in the dropdown.
Thanks for the help so far! The template not being added to the document type was indeed the problem with the dropdown. I am still getting the error but I think we are close to fixing it. Here is the current status:
The errorpage is now using the template PageNotFound
Which is inheriting Subpage like below (not sure if this is correct)
Yes, almost there! In your pageNotFound.cshtml, you should now change the @inherits Umbraco.Web.Mvc.UmbracoViewPage<[Redacted].Web.ViewModels.Subpage> to @inherits Umbraco.Web.Mvc.UmbracoViewPage<[Redacted].Web.ViewModels.PageNotFound>
As the page should expect a model of type PageNotFound instead of type Subpage
YESSSSSS IT WORKS! Amazing help, thanks so much for the step-by-step help and patience! Based on your name I am thinking you are Dutch? Could you send me your IBAN or create a tikkie?
It looks there is some thing to do with template assign. If you assign wrong template in 404 document type then this issue will come. In your 404 page, please make sure you do not have subpage template assigned?
PAYING 50 EUR - Help me fix Umbraco.Web.Mvc.ModelBindingException
Anyone know what may be the issue? I am getting this error:
Umbraco.Web.Mvc.ModelBindingException: Cannot bind source content type [redacted].Web.ViewModels.PageNotFound to model type [redacted].Web.ViewModels.Subpage.
The error arises when trying to load a 404 error page of document type 'Errorpage'. I am new to Umbraco so I am not entirely sure how to decode the message, but googling suggests that it may be because of this line in /Views/Subpage.cshtml?
@inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.Subpage> @using ContentModels = Umbraco.Web.PublishedModels
After spending so much time trying to fix this I am pretty desperate at this point so I am paying 50 eur if you can help me fix this (although transaction costs may be deducted from this if you're outside the EU)
Hi,
Your issue here is that the code is trying to render a .cshtml page that is expecting a
[redacted].Web.ViewModels.Subpage
(coming from the@inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.Subpage>
), however your code is sending a[redacted].Web.ViewModels.PageNotFound
thus is cannot render the view due to a wrong modelCould you try changing
@inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.Subpage>
to@inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.PageNotFound>
?Thanks for the response. The thing that confuses me is that there is no template for pageNotFound, only for subpage.
This line is in the Subpage template
@inherits Umbraco.Web.Mvc.UmbracoViewPage<[redacted].Web.ViewModels.Subpage>
. The Subpage template is used successfully for some other pages so I I think if I changeViewModels.Subpage
toViewModels.PageNotFound
it would break those.Honestly, I am confused about where pageNotFound even gets
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Raido.Web.ViewModels.Subpage>
from as in the I can't find pageNotFound document type I can't find any reference to Subpage...BTW, I inherited this codebase and was thrown in the deep end as I never worked with Umbraco before so my apologies if I am not much help.
Yeah, if you would change that line while it is used in other places, it will break them.
The reference to the template could come from a few places. You could check the following:
IContentLastChanceFinder
. The template could also be set dynamically in this finder.Best thing would probably be to either have the PageNotFound document type inherit from the Subpage so that you can use the same template. Or create a specific pageNotFound template and link it with that.
This was actually the case! There are no dropdown options but when I select open it open the Subpage template.
I am down for either solution but I get stuck here:
For the first solution, I'm in the PageNotFound document type but I don't know how to change it to inherit from the Subpage document type. Following this article I went into
Compositions
and I see an option to select/Layout/Reusable ribbons/reusable ribbons
but no option for the Subpage document type which is/Layout/Reusable ribbons/Subpage
For the second solution, I created another template pageNotFound.cshtml but I can't select the error page to use this as the dropdown is empty.
For the first solution, you'll probably have to move the PageNotFound document type to be under the Subpage document type. Ofcourse, I don't know the complete structure of your Umbraco, so I would suggest trying to do the second solution first.
As for the second solution. Did you also add the new template to your document type here?
If it isn't added there, then it also won't show as one of the options in the dropdown.
Thanks for the help so far! The template not being added to the document type was indeed the problem with the dropdown. I am still getting the error but I think we are close to fixing it. Here is the current status:
The errorpage is now using the template PageNotFound
Which is inheriting Subpage like below (not sure if this is correct)
Yes, almost there! In your pageNotFound.cshtml, you should now change the
@inherits Umbraco.Web.Mvc.UmbracoViewPage<[Redacted].Web.ViewModels.Subpage>
to@inherits Umbraco.Web.Mvc.UmbracoViewPage<[Redacted].Web.ViewModels.PageNotFound>
As the page should expect a model of type PageNotFound instead of type Subpage
YESSSSSS IT WORKS! Amazing help, thanks so much for the step-by-step help and patience! Based on your name I am thinking you are Dutch? Could you send me your IBAN or create a tikkie?
Great to hear that it works! And don't worry about the money, I am just glad to help people out.
Very generous of you, I'll pay it forward!
Hi,
It looks there is some thing to do with template assign. If you assign wrong template in 404 document type then this issue will come. In your 404 page, please make sure you do not have subpage template assigned?
Thanks,
Pasang
is working on a reply...