I was able to break the dependancy on RenderModel in my MVC pages, but for some reason my web pages think I'm passing RenderModels to my views. I've followed the documentation on http://our.umbraco.org/documentation/reference/mvc/custom-controllers, and various guides. But I'm still getting the error "The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'TestSurfaceController.UserModel'."
namespace TestSurfaceController { public class UserModel { [Required] public string FirstName { get; set; } [Required] public string LastName { get; set; } [Required] [EmailAddress] public string EmailAddress { get; set; } [Required] public string Username { get; set; } [Required] public string Password { get; set; } [Compare("Password")] public string ConfirmPassword { get; set; } } }
The view:
@model TestSurfaceController.UserModel
@using(Html.BeginUmbracoForm("HandleFormSubmit")) { *the html that makes my form* }
And the the important bit of the controller:
namespace TestSurfaceController { public class UserRegistrationController : SurfaceController { /* * This action returns a fresh index view of the User Registration page. */ public ActionResult Index() { return PartialView("UserRegistration", new UserModel()); } ... more code
As you can see, the UserModel doesn't inherit from RenderModel, and it's the model being passed to the view.
I'm currently running Umbraco 7.2.0. Any help would be greatly appreciated!
Thank you for the reply! Unfortunately, extending RenderMvcController didn't solve the problem. Strangely enough, replacing the inherits statement in the template with
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
makes everything work. Do you have any idea why this happens?
Reversed RenderModel Dependancy Issue
Hi all,
I was able to break the dependancy on RenderModel in my MVC pages, but for some reason my web pages think I'm passing RenderModels to my views. I've followed the documentation on http://our.umbraco.org/documentation/reference/mvc/custom-controllers, and various guides. But I'm still getting the error "The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'TestSurfaceController.UserModel'."
Layout currently inherits from
Here's my template:
The model:
The view:
And the the important bit of the controller:
As you can see, the UserModel doesn't inherit from RenderModel, and it's the model being passed to the view.
I'm currently running Umbraco 7.2.0. Any help would be greatly appreciated!
Hello again,
I updated my MVC to clear up any specific routing issues, but the problem is still occuring. I'm still running Umbraco 7.2.0.
My document type is now named and aliased UserRegistration.
The Layout inherits from:
The new UserRegistration template:
The updated model:
The updated view:
And finally, the updated controller:
If possible, I'd like to avoid extending RenderModel with my models because it seems a little limiting. Any help would be greatly appreciated!
Hello,
The SurfaceController is for posting. If you want to use route hijacking you need to use RenderMvcController or add an interface to your SurfaceController. You can find an example in the Hybrid Framework.
Jeroen
Thank you for the reply! Unfortunately, extending RenderMvcController didn't solve the problem. Strangely enough, replacing the inherits statement in the template with
makes everything work. Do you have any idea why this happens?
is working on a reply...