ASP.NET MVC A potentially dangerous Request.Form value was detected from the client when using a custom modelbinder

You have a few options. On the model add this attribute to each property that you need to allow HTML – best choice using System.Web.Mvc; [AllowHtml] public string SomeProperty { get; set; } On the controller action add this attribute to allow all HTML [ValidateInput(false)] public ActionResult SomeAction(MyViewModel myViewModel) Brute force in web.config – definitely … Read more

Custom DateTime model binder in Asp.net MVC

you can change the default model binder to use the user culture using IModelBinder public class DateTimeBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); bindingContext.ModelState.SetModelValue(bindingContext.ModelName, value); return value.ConvertTo(typeof(DateTime), CultureInfo.CurrentCulture); } } public class NullableDateTimeBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); … Read more