码迷,mamicode.com
首页 > 其他好文 > 详细

从客户端检测到有潜在危险的Request.Form值

时间:2014-05-15 15:54:44      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   c   

1.带有html标记内容提交(使用web编辑器)

js:

bubuko.com,布布扣
    <script type="text/javascript">
        //简单模式
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create(‘textarea[name="Content"]‘, {
                resizeType: 1,
                allowPreviewEmoticons: false,
                allowImageUpload: false,
                items: [
                        ‘fontname‘, ‘fontsize‘, ‘|‘, ‘forecolor‘, ‘hilitecolor‘, ‘bold‘, ‘italic‘, ‘underline‘,
                        ‘removeformat‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘, ‘insertorderedlist‘,
                        ‘insertunorderedlist‘, ‘|‘, ‘emoticons‘, ‘image‘, ‘link‘
                ]
            });
        });
    </script>
bubuko.com,布布扣

cshtml:

bubuko.com,布布扣
        @using (Html.BeginForm("Add"))
        {
            <table border="0" width="100%">
                <tr>
                    <td>标题:
                    </td>
                    <td>
                        <input type="text" name="Title" />
                    </td>
                </tr>
                <tr>
                    <td>内容:
                    </td>
                    <td>
                        <textarea name="Content" cols="30" rows="10"></textarea>
                    </td>
                </tr>
            </table>
            <input type="submit" value="保存内容" />
        }

        @if (ViewBag.Success == 1)
        {
            @:<script> alert("添加成功"); </script> 
        }
bubuko.com,布布扣

C#:

解决方案1:

bubuko.com,布布扣
        //新增文章内容
        [ValidateInput(false)]
        public ActionResult Add(string Title = "", string Content = "")
        {
            if (Title.Length > 0)
            {
                AddArticle(Title, Content);
            }
            return View();
        }
bubuko.com,布布扣

解决方案2:(失败)

bubuko.com,布布扣
        //新增文章2
        public ActionResult AddTwo(string Title = "", string Content = "")
        {
            this.ValidateRequest = false;//此处禁用请求验证不起作用
            if (Title.Length > 0)
            {
                AddArticle(Title, Content);
            }
            return View();
        }
bubuko.com,布布扣

 

从客户端检测到有潜在危险的Request.Form值,布布扣,bubuko.com

从客户端检测到有潜在危险的Request.Form值

标签:style   blog   class   code   java   c   

原文地址:http://www.cnblogs.com/tianmahygj/p/3726668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!