在我的asp.net mvc4应用程序中,例如在创建新项目“cond”时,出现此错误“从客户端检测到潜在危险的Request.Form值”。 cond是数据库中具有两个字段“id_regle”和“cond_txt”的表。 cond_txt字段将具有以下形式的条件“left_side + op + right_side”; op = <,>,== .... 我尝试了不同的建议,我发现,但他们没有为我工作,禁用此验证。在MVC 4中禁用客户端验证提交按钮
这是视图 “创造”:
@model MvcApplication3.cond
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>cond</legend>
<div class="editor-label">
@Html.LabelFor(model => model.cond_txt)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.cond_txt)
@Html.ValidationMessageFor(model => model.cond_txt)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.id_regle, "regle")
</div>
<div class="editor-field">
@Html.DropDownList("id_regle", String.Empty)
@Html.ValidationMessageFor(model => model.id_regle)
</div>
<p>
<input type="submit" value="Create" class="cancel" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
这是控制器:
public ActionResult Create()
{
ViewBag.id_regle = new SelectList(db.regle, "id", "action");
return View();
}
//
// POST: /Default2/Create
[HttpPost]
public ActionResult Create(cond cond)
{
if (ModelState.IsValid)
{
db.cond.AddObject(cond);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.id_regle = new SelectList(db.regle, "id", "action", cond.id_regle);
return View(cond);
}
我试着在web.config中加入validateRequest = “假”,但没有为我工作 任何建议plz
http://stackoverflow.com/questions/81991/a-potentially-dangerous-request-form-value-was-detected-from-the可能duplivate - 客户 – 2015-04-03 09:50:18
在哪里把validateRequest =“false”?在mvc4 asp.net – 2015-04-03 10:14:58
我在web.config中的中尝试过,但没有奏效 –
2015-04-03 10:16:52