独自のモデルバインダーを実装できます
public class DecObjModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext,
ModelBindingContext bindingContext)
{
//make a instance of your object
var myObj = new DecObj()
//bind the properties from my obj
myObj.Title= bindingContext
.ValueProvider
.GetValue("Title") // The Property name sent from the browser
.ToString();
/* then the property you want to decrypt */
var encBody = bindingContext
.ValueProvider
.GetValue("EncBody") // The Property name sent from the browser
.ToString();
/* decryption logic here to the encBody then after assign the decrypted value to myObj*/
return myObj;
}
次にModelBinder
、Global.asxのApplication_Startに次の方法で登録します。ModelBinders.Binders.Add(typeof(DecObj), new DecObjModelBinder());