asp.net-mvc – 检测到潜在的危险Request.Form值
发布时间:2020-05-23 12:13:02 所属栏目:asp.Net 来源:互联网
导读:我有一个wmd编辑器的表单。输入文本区域使用: %: Html.TextAreaFor(t = t.NewsBody, new{@class=wmd-panel, id=wmd-input}) % 每次提交表单我得到一个潜在的危险Request.Form值从客户端检测到 我尝试在action方法上设置[ValidateInput(false)],我尝试添加 h
|
我有一个wmd编辑器的表单。输入文本区域使用: <%: Html.TextAreaFor(t => t.NewsBody,new{@class="wmd-panel",id="wmd-input"}) %>
每次提交表单我得到一个潜在的危险Request.Form值从客户端检测到 我尝试在action方法上设置[ValidateInput(false)],我尝试添加 有任何想法吗? 编辑 行动方式: [ILFFAuthorize(Roles = "Admin")] // this is a custom auth attrobite
[HttpPost]
[ValidateInput(false)]
public ActionResult AddNews(FormCollection col){
//public ActionResult AddNews(News news)
//{
if (ModelState.IsValid)
{
News news = new News();
news.NewsDate = DateTime.Now;
news.NewsPosterId = 0;
news.NewsTitle = col["NewsTitle"];
news.NewsBody = col["NewsBody"];
newsRepository.Add(news);
newsRepository.Save();
return RedirectToAction("Index","Home");
}
else
{
return View();
}
}
解决方法你需要把它放在你的[HttpPost]动作方法之上[HttpPost]
[ValidateInput(false)]
public ActionResult Edit(FormCollection collection) {
.....
}
如果你使用MVC3,那么你不应该使用[ValidateInput(false)],而是使用[AllowHtml],这里说明的是:http://dailydotnettips.com/2011/08/24/how-to-allow-user-to-input-html-in-asp-net-mvc/ 还有:尝试将[HttpPost]上面的[ValidateInput(false)]放在下面,我记得这些都是从上到下执行的。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- entity-framework – 在Enitity Framework中使用Asp.net身份
- asp.net – ClientScriptManager.GetPostBackEventReferenc
- asp.net-mvc-2 – ASP.NET MVC2 Ninject NLog(shared hosti
- asp.net-mvc – 如何在Html.RenderAction(MVC3)中发送模型对
- asp.net-mvc – 如何在我的项目中实现强大的每个请求模式,同
- asp.net-web-api – Web Api使用IDependencyResolver补充启
- asp.net-mvc-3 – 在动作过滤器中获取动作参数的值
- ASP.NET成员资格 – 让用户使用以前的密码
- asp.net-mvc – 如何让Visual Studio 2012检测虚拟目录是否
- .net – 如何在ASP成员资格中使用LogOut
推荐文章
站长推荐
- asp.net-mvc – Kendo Grid Edit InLine Custom
- ASP.NET AJAX日历扩展程序日期格式
- asp.net-mvc – 什么是强类型的视图在ASP.NET MV
- asp.net – 在IIS 7.5上挂在Session模块上的请求
- asp.net-mvc-3 – Mvc 3图像上传库
- asp.net – 对象不是垃圾回收,但不包含gcroot
- asp.net-mvc – 以Razor语法为Telerik MVC Grid定
- asp.net – 在MVC 4.0中使用部分视图中的节
- asp.net – 太多的Cookie OpenIdConnect.nonce导
- 启动asp.net输出缓存
热点阅读
