protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // Specify the default storage mode, and encryption keys var config = new MvcTricks.RoundTripModelBinding.Configuration( StorageModes.CompressAndEncrypt, Encoding.Default.GetBytes("Lorem ipsum dolor sit amet amet."), // 32 bytes Key Encoding.Default.GetBytes("Donec tincidunt.") // 16 bytes IV ); MvcTricks.RoundTripModelBinding.Configuration.RegisterSerializationHandlerFor<System.Net.Mail.MailAddress>( s => { return "*****@*****.**"; }, d => { return new System.Net.Mail.MailAddress("*****@*****.**"); } ); // Add the modelbinder as the default modelbinder: ModelBinders.Binders.DefaultBinder = new MvcTricks.RoundTripModelBinding.DefaultModelBinder(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // Specify the default storage mode, and encryption keys var config = new MvcTricks.RoundTripModelBinding.Configuration( StorageModes.CompressAndEncrypt, Encoding.Default.GetBytes("Lorem ipsum dolor sit amet amet."), // 32 bytes Key Encoding.Default.GetBytes("Donec tincidunt.") // 16 bytes IV ); MvcTricks.RoundTripModelBinding.Configuration.RegisterSerializationHandlerFor <System.Net.Mail.MailAddress>( s => { return("*****@*****.**"); }, d => { return(new System.Net.Mail.MailAddress("*****@*****.**")); } ); // Add the modelbinder as the default modelbinder: ModelBinders.Binders.DefaultBinder = new MvcTricks.RoundTripModelBinding.DefaultModelBinder(); }