ASP.NET MVC 5 从客户端检测到一个潜在危险的 Request.Form 值。

24 浏览
0 Comments

ASP.NET MVC 5 从客户端检测到一个潜在危险的 Request.Form 值。

我试图向一个动作发送一个表单请求,其中一个输入是来自包含HTML标记的文本编辑器。问题是我得到了以下错误:

客户端检测到一个潜在危险的Request.Form值

同时我在模型中加入了[AllowHtml]:

[UIHint("Html")]
    [AllowHtml]
    [Display(Name = "Description")]
    public string Description { get; set; }

并且在动作中添加了以下代码:

[HttpPost]
    [ValidateInput(false)]
    [ValidateAntiForgeryToken]
    public virtual async Task Create(ProductViewModel viewModel)
    {
        if (!ModelState.IsValid)
        {
            var groups = await _groupService.GetAllAsync();
            viewModel.GroupList =
                groups.Select(p => new SelectListItem {Text = p.Title, Value = p.Id.ToString()}).ToList();
            return View(viewModel);
        }
        _productService.Insert(viewModel);
        return RedirectToAction("Index");
    }

那么问题是什么?

0