I am getting the following Error The model item passed into the dictionary is of type 'MvcWebApplication.Models.Product' but this dictionary requires a model item of type 'MvcWebApplication.ViewModels.ProductCommonViewModel'.
Controller Code is as follows:-
public ActionResult Index([Bind(Prefix= "MvcWebApplication.ViewModels.ProductCommonViewModel")] Product product)
View Model class sent to the View:
namespace MvcWebApplication.ViewModels
{
public class ProductCommonViewModel
{
public Product Product { get; set; }
}
}
Model Binder :
namespace MvcWebApplication.ModelBinders
{
public class ProductBinder : IModelBinder
{
#region IModelBinder Members
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
HttpRequestBase fc = controllerContext.HttpContext.Request;
Product product = new Product();
LaunchSheet launchSheet = null; ;
ProductPricing productPricing = null;
product.LoanTypeId = Convert.ToInt32(fc["rblLoanType"]);
product.ProductTypeId = Convert.ToInt32(fc["ddlproductType"]);
etc...
return Product;
}
}
}
Product Class
[ModelBinder(typeof(ProductBinder))]
public partial class Product : IRuleEntity
{
}
What am I doing wrong?