Adding different models in view as well as in layout page RRS feed

  • Question

  • I am new to MVC.I am working on MVC with entity framework . I am using a function which returning List of objects .

    Adding below code on view.

     @model IEnumerable<WWM.DataModel.Helpers.StatesWithProperties>
        @{Layout = "~/Views/Shared/_Layout.cshtml";

    and my controller is like below

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using WWM.DataModel.Controllers;
    using WWM.DataModel.Helpers;

    namespace WWM.Website.Controllers
        public class AllListingsController : Controller
            // GET: AllListings
            public ActionResult Index()
                EntityController Obj = new EntityController();
           List<StatesWithProperties> StateWithPropertiesList=new List<StatesWithProperties>();
                //return View(StateWithPropertiesList);
                return PartialView(StateWithPropertiesList);

    but in layout page I have something like below.

    @model WWM.Website.Models.BaseViewModel

    and while running project getting below error

    The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[WWM.DataModel.Helpers.StatesWithProperties]', but this dictionary requires a model item of type 'WWM.Website.Models.BaseViewModel'.

    What is the proper solution of this.

    Tuesday, December 1, 2015 10:54 AM