Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器 软件资源

软件开发小程序制作系统集成与运维空间租用硬件开发视频监控技术咨询与支持——联系电话:0311-88999002/88999003

首页 / 脚本样式 / 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 ();" }))