I have created a controller that has models. I am trying to add the model to a partial view, passing in the result of a controller method.
Controller / Model:
public class Models : RenderModel
{
public class Posts : Models
{
public string postMessage { get; set; }
public string profileImage { get; set; }
}
}
View:
@inherits UmbracoViewPage<UFaceAuth.Controllers.FacebookHelperController.Models.Posts>
@{
UFaceAuth.Controllers.FacebookHelperController facebook = new
UFaceAuth.Controllers.FacebookHelperController();
}
@Model
Error:
Cannot bind source type Umbraco.Web.Models.RenderModel`1[Umbraco.Web.PublishedContentModels.Home] to model type UFaceAuth.Controllers.FacebookHelperController+Models+Posts.
I'm experiencing the same problem in Umbraco 7.4.2, can't make route hijacking and custom template model working, with the same error.
thinking in an umbraco bug...
by now i've been forced to encapsulate all in a partial view and render it with Html.Action called from the main Template view, but this is totally useless and confusionary for the project.
please if umbraco bug fix this soon, cause is really a problem not be able to use the standard umbraco inheritance
public class MyCustomModel : RenderModel
{
public MyCustomModel (IPublishedContent content)
: base(content)
{
//constructor
}
}
Controller
public class MyCustomController : RenderMvcController
{
public override ActionResult Index(RenderModel umbracoModel)
{
MyCustomModel model = new MyCustomModel(umbracoModel.Content);
return CurrentTemplate(model);
}
}
adding model to partial view
I have created a controller that has models. I am trying to add the model to a partial view, passing in the result of a controller method.
Controller / Model:
View:
Error:
Cannot bind source type Umbraco.Web.Models.RenderModel`1[Umbraco.Web.PublishedContentModels.Home] to model type UFaceAuth.Controllers.FacebookHelperController+Models+Posts.
Can anyone explain why this is happening please?
I'm experiencing the same problem in Umbraco 7.4.2, can't make route hijacking and custom template model working, with the same error. thinking in an umbraco bug... by now i've been forced to encapsulate all in a partial view and render it with Html.Action called from the main Template view, but this is totally useless and confusionary for the project. please if umbraco bug fix this soon, cause is really a problem not be able to use the standard umbraco inheritance
Here's the code: View
Model
Controller
I'm having the same issue after upgrading to 7.4.2.
I had custom routes that were using models inheriting from RenderModel. Now I'm getting the error:
NOTE: My hijacked routes were working perfectly on 7.4.1
We have the same issue in Umbraco Cloud solution, version 7.5.14
This is a bug in Umbraco that is (supposedly) getting sorted out in 7.4.3.
See the following post for a temporary solution: https://our.umbraco.org/forum/using-umbraco-and-getting-started/75998-update-to-742-all-custom-hijacked-controllers-stopped-working
is working on a reply...