Tom Limpens Tom Limpens - 3 years ago 196
ASP.NET (C#) Question

ASP.NET model won't load my repository

When I try to load my repository into my view like this

@model BlueRateITRepositories.Repository.FilmRepository;
ViewBag.Title = "Films";


The model gives the error "'FilmRepository' is a type which is not valid in the given context"

Controller code

FilmRepository FilmRepository = new FilmRepository();

// GET: Film
public ActionResult Films()
return View(FilmRepository);

Can anyone help me fix this?

Answer Source

Remove the semicolon at the end of your model declaration.And also, as suggested by @shyju , try keeping the object name in a different casing than the class name.

Model declaration should be-


Let me know if it works.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download