Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am curious to understand how I can pass my CustomViewModel to the view without invoking this ModelBindingException:
Cannot bind source type Umbraco.Web.Models.ContentModel to model type legimusWeb.ViewModels.LoginViewModel.
Whenever I use SurfaceController on my controller my view excepts Umbraco.Web.Models.ContentModel for this I can somewhat understand, I am guessing surfaceController wants me to send one of my built models to the view.
I could fix this by changing my View:
But what happens now if I am using an API request to get xml or json information that I need to deseralize to an custom object and use this to create a condition on my view. It won't work.
Model = MyCustomModel.cs
UserInformationModel = a object property in MyCustomModel.cs
userRole = a string property in my UserInformationModel.cs
If I am using SurfaceController this is not possible due to @Model won't be referring to MyCusomtViewModel.cs but instead to the generated Login model.
I could fix this by inherit the RenderMvcController in my controller class but that would mess up my routing to the different pages i want to navigate for the different userRole that exists in my API request.
@AuthenticateController : SurfaceController
@AuthenticateController : Umbraco.Web.Mvc.RenderMvcController
Thanks for reading and hope someone could help me figure out how I can pass my CustomViewModel.cs with surfaceController.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted