我看到在我MVC3应用一个奇怪的行为。 我有一个由阿贾克斯称为行动,并接收与HTML文本的帖子。 我想允许HTML的进入,所以我设置ValidateInput(假)属性。 我也有这个参数的全球性的OutputCache过滤器:(NoStore = TRUE,持续时间= 0,VaryByParam时= “*”)
代码如下所示:
[HttpPost]
[ValidateInput(false)]
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*" )]
public ActionResult Edit(SomeModel someModel)
{
saveModel(someModel);
return new AjaxEditSuccessResult();
}
当我发个帖子说的方法,它是执行和模型被保存,但我得到的回应是标准的错误信息,这个堆栈跟踪“从客户端检测到有潜在危险的Request.Form值”:
[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (text="<p class="MsoNormal"...").]
System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +9665149
System.Web.<>c__DisplayClass5.<ValidateHttpValueCollection>b__3(String key, String value) +18
System.Web.HttpValueCollection.EnsureKeyValidated(String key) +9664565
System.Web.HttpValueCollection.Get(String name) +17
System.Web.Caching.OutputCacheModule.CreateOutputCachedItemKey(String path, HttpVerb verb, HttpContext context, CachedVary cachedVary) +676
System.Web.Caching.OutputCacheModule.CreateOutputCachedItemKey(HttpContext context, CachedVary cachedVary) +55
System.Web.Caching.OutputCacheModule.OnLeave(Object source, EventArgs eventArgs) +9716788
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
你知道,如果我能以任何方式表明对属性的OutputCache,它需要尊重ValidateInput属性?