Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public class ProfileModelBinder : IModelBinder
  2. {
  3. public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
  4. {
  5. if (bindingContext.Model != null)
  6. throw new InvalidOperationException("Cannot update instances");
  7.  
  8. Profile p = (Profile)controllerContext.HttpContext.Session[BaseController.profileSessionKey];
  9. if (p == null)
  10. {
  11. p = new Profile();
  12. controllerContext.HttpContext.Session[BaseController.profileSessionKey] = p;
  13. }
  14. return p;
  15. }
  16. }
  17.  
  18. public ActionResult MyAction(Profile currentProfile)
  19. {
  20. // do whatever..
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement