首页 / 脚本样式 / jQuery / 利用jquery解决MVC下…问题
利用jquery解决MVC下…问题2011-11-10 博客园 柯南利用jquery解决MVC下A potentially dangerous Request.QueryString value was detected from the client问题其实A potentially dangerous Request.QueryString value was detected from the client错误原 因是mvc检测了您的请求,如果有‘<’等字符串,就会有这个错误。解决办法在action前 加[AcceptVerbs(HttpVerbs.Post),ValidateInput(false)]
public ActionResult New(string xmlContent) {
…
但是如果你在action中
return View();
还是会出现这个错误,除非return RedirectToAction("Result");
转到另一个action
解决方法1:1.利用jquery的decodeURI和encodeURI方法编码字符串。例如:您要提交的field名字是xmlContent那么填写如下代码1.<% using (Html.BeginForm ("New", "XML", FormMethod.Get, new { @onsubmit = "return CheckForm ();" }))