2011-01-22 45 views

回答

5
  1. 您还需要在ASP.NET 4.0中设置<httpRuntime requestValidationMode="2.0"/>
  2. 与ASP.NET MVC 2(.NET 4.0)中的相同,但此外,您可以使用[AllowHtml]属性进行更细粒度的控制,该属性可放置在视图模型的单个属性上,而不是禁用整个请求:

    public class MyViewModel 
    { 
        [AllowHtml] 
        public string SomeHtmlProperty { get; set; } 
    
        public string SomeOtherProperty { get; set; } 
    } 
    

和有一个这样的控制器动作:

[HttpPost] 
public ActionResult Update(MyViewModel model) { ... }