I have a old api that receives an encrypted request and encrypts the response once complete. I am attempting to switch this to mvc4 webapi and it has gone smooth until I hit this encryption. What I need is a way to decrypt the request when it comes in so mvc will act on it properly. Also once the process is complete encrypt the response before sending it. I do not want to place the encryption parts in each action.
Note: The body is still properly formatted as a single item, so I would push it all through a single action with a selector of my own, but would prefer a more proper rest style implementation.
you can implement your own model binder
and then You register the
ModelBinder
in Global.asx in Application_Start via:ModelBinders.Binders.Add(typeof(DecObj), new DecObjModelBinder());
You should be able to do this with a MessageHandler. There are a bunch of examples of how to create MessageHandlers in WebAPIContrib