i having error throw on View page and i think i am passing wrong type, can anybody please correct me - thanks.
The model item passed into the dictionary is of type 'System.Collections.Generic.List1[App.Domain.Model.Interface.IPerson]' but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1[App.Domain.Service.PersonService]'.
MyService looks like this....
namespace App.Domain.Service
{
public class PersonService : IPersonService
{
private IPersonRepository _personRepository;
public PersonSe开发者_开发百科rvice(IPersonRepository personRepository)
{
_personRepository = personRepository;
}
public List<IPerson> GetPerson()
{
return _personRepository.GetHost();
}
}
}
myView look like this...
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<IEnumerable<App.Domain.Service.PersonService>>" %>
my controller look like this...
public ActionResult GetPersons()
{
IPersonRepository personRepo = new PersonRepository();
PersonService person = new PersonService(personRepo);
IList<IPerson> p = person.GetPerson();
return View(p);
}
You are sending the wrong type to the View() In your View decleration says App.Domain.Service.PersonService, but in your View you are sending it a View(IPerson). If you want to send an IPerson to your view the tag should read like:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<App.Domain.Model.Interface.IPerson>>" %>
精彩评论