Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ProfileModelBinder : IModelBinder
- {
- public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
- {
- if (bindingContext.Model != null)
- throw new InvalidOperationException("Cannot update instances");
- Profile p = (Profile)controllerContext.HttpContext.Session[BaseController.profileSessionKey];
- if (p == null)
- {
- p = new Profile();
- controllerContext.HttpContext.Session[BaseController.profileSessionKey] = p;
- }
- return p;
- }
- }
- public ActionResult MyAction(Profile currentProfile)
- {
- // do whatever..
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement