Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法检测用户何时将 HTML 代码放入控制器操作参数中,以便我可以在 ASP.NET MVC 4 中显示适当的错误消息?默认情况下,没有属性和方法参数接受 HTML。
我还想在客户端强制执行此验证。
public class MyViewModel { [AllowHtml] [RegularExpression(@"^((?!<\w+>).)*$", ErrorMessage = "Please do not use HTML tags")] public string SomeValue { get; set; } }