Author: Scott Hanselman's Computer Zen - ASP.NET | Posted on: 2/6/2009 12:39:53 PM | Views : 1303

ModelBinders are great. I've blogged a bit about them before like the File Upload Model Binder . I am working on some code like this: [Authorize] public ActionResult Edit(int id) { Dinner dinner = dinnerRepository.FindDinner(id); if (dinner.HostedBy != User.Identity.Name) return View("InvalidOwner"); var viewModel = new DinnerFormViewModel { Dinner = dinner, Countries = new SelectList(PhoneValidator.Countries, dinner.Country) }; return View(viewModel); } It's pretty straight forward, but this Controller knows too much. It's reaching into implicit parameters. The id was passed in, but the User is actually a property of the Controller base class and ultimately requires an HttpContext. Having this method "know" about...(read more) ...

Go to the complete details ...