Data validation ASP MVC OnActionExecuting

googleuit322

New Member
I have created a base controller that each of my controllers inherit. In this controller I have the OnActionExecuting method. I use this to check the url for some parameters. The problem I have is that I get an exception whenever I post html data. I have setup the model using the [AllowHTML] tag and it works on all the other actions. How do I make the OnActionExecuting method pay attention to the model validation?This is what I have in my base controller\[code\]public abstract class BaseController : Controller{ [ValidateInput(false)] protected override void OnActionExecuting(ActionExecutingContext filterContext) { if ((Request.Params["api"] == null || string.IsNullOrEmpty(Request.Params["api"]))) return; if ((Request.Params["api"] != null && !string.IsNullOrEmpty(Request.Params["api"]))) { if (Session["api"] == null) { Session["api"] = Request.Params["api"]; } } }\[/code\]and below is an extract from my model\[code\][MetadataType(typeof (MessagingMetaData))]public partial class Message{}public class MessagingMetaData{ [Required] [Display(Name = "Message")] [DataType(DataType.Html)] [AllowHtml] public string Body { get; set; }}\[/code\]
 
Back
Top