我有一个网站托管在亚马逊Linux AMI盒运行mono通过lighttpd。在我的网站的管理部分,我有一个表单,让我可以创建博客条目。由于我希望能够存储html,因此我将我的保存控制器操作设置如下:
[Authorize(Roles = "Admin")]
[HttpPost, ValidateInput(false)]
public ActionResult CreateBlog(Blog model) {
if (ModelState.IsValid) {
ContextFactory.BlogManager.Save(model);
return RedirectToAction("Blogs");
}
return View(model);
}一切都在本地正常运行,但当我将代码部署到我们的amazon实例时,我得到了以下异常:
A potentially dangerous Request.Form value was detected from the client (Body=\"asd<br>asdas\").
System.Web.HttpRequestValidationException: A potentially dangerousr> Request.Form value was detected from the client (Body=\"asd<br>asdas\").<br>
at System.Web.HttpRequest.ThrowValidationException (System.String name, System.String key, System.String value) [0x00000] in <filename unknown>:0 <br>
at System.Web.HttpRequest.ValidateString (System.String key, System.String value, RequestValidationSource source) [0x00000] in <filename unknown>:0 <br>
at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazyWebROCollection.Validate (System.String key, System.String value) [0x00000] in <filename unknown>:0 <br>
at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazyWebROCollection.Get (System.String name) [0x00000] in <filename unknown>:0 <br>
at System.Collections.Specialized.NameValueCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0 <br>
at ...有什么想法吗?
发布于 2011-05-12 21:04:03
实际上,我可以通过在我的web.config中添加<httpRuntime requestValidationMode="2.0"/>来修复它
发布于 2011-05-12 08:50:42
听起来像是要回发的数据包含<。这是不允许的,以防止可能的脚本注入攻击。Here's a previous question上的这个话题应该能对你有所帮助。
https://stackoverflow.com/questions/5971480
复制相似问题