This error throws me when I am pass data to the model and call the view.
Here is the full error shows,
An unhandled exception occurred while processing the request. InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'Castle.Proxies.VendorProxy', but this ViewDataDictionary instance requires a model item of type 'System.Collections.Generic.IList`1[Nop.Web.Models.Common.VendorDetailModel]'.
Now, I create one model, one view and controller in nopcommerce 4.2.
Here is my model place,
Nop.Web => Models => Common => VendorDetailModel
Here is the code of model
public VendorDetailModel()
{
Address = new List<AddressModel>();
}
public string Name { get; set; }
public IList<AddressModel> Address { get; set; }
Here is the controller placed
Nop.Web => Controllers => CommonController => Vendordetail(method)
Here is the controller code
public virtual IActionResult Vendordetail(int vendorId)
{
var model = _vendorService.GetVendorById(vendorId);
return View("Vendordetail",model);
}
Here is the view placed,
Nop.Web => Views => Common => Vendordetail.cshtml
Here is the view code
@model VendorDetailModel
content.......
So, this error is showing when I place the @model VendorDetailModel in view file while if I remove this line then error is not showing. But I remove this line then how can I get the value without model.