I am trying to learn ASP.Net MVC from the asp.net website sample application MVCMovieApplication. This application was written for MVC3. I am stuck at the below part. Can someone help me with this issue?
public ActionResult Edit(int id = 0)
{
Movie movie = db.Movies.Find(id);
if (movie == null)
{
return HttpNotFound();
}
return View(movie);
}
Error:
The Name 'HTTPNotFound' does not exist in the current context.
The HttpNotFound method and the related HttpStatusCodeResult and it’s inheritors like
HttpNotFoundResultare new features added in MVC3. That why it’s not working in MVC2.So either you upgrade to MVC3 (even MVC4 is released as RTM as of this week)
or you can create your own
ActionResultto return the 404 status code:And you in your action method: