In this tutorial in Details action Scott uses
if (dinner == null)
return View("NotFound");
else
return View("Details", dinner);
to return 404 Not Found message view.
But in my downloaded source code for NerdDinner there are these lines:
if (dinner == null) {
return new FileNotFoundResult { Message = "No Dinner found for that id" };
}
This goes to FileNotFoundResult where there is this:
public class FileNotFoundResult : ActionResult
{
public string Message {
get;
set;
}
public override void ExecuteResult(ControllerContext context) {
throw new HttpException(404, Message);
}
}
And that's it. How is the reference to NotFound.aspx view made from here on? I was unable to found out how this gets mapped to NotFound.aspx, though NotFound.aspx does exist in Dinners view folder. There's also nothing in web.config..
The above code is from Change Set 41262 not the 1.0 version.
Question (to be more clear about it): How come "throw new HttpException(404, message)" returns NotFound view??
Someone please explain.