2011-01-22 46 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) { ... }