UEditor 富文本向.net后台传值问题解决方案

1、前台富文本用编码函数编码(到后台自动解码):

encodeURIComponent(UM.getEditor('myEditor').getContent()

2、后台修改web.config

<configuration> 
<system.web> 
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
<pages validateRequest="false" /> 
</system.web> 
</configuration> 

3、特性来关闭前端危险文本验证: [ValidateInput(false)]
4、手动编写反序列化方法:

private NS_FEEDBACK DesearilizeJsonStrToFeebbackInstance()
{
   NS_FEEDBACK fb = new NS_FEEDBACK();
   this.ValidateRequest = false;
   string jsonStr = Request.Form[0];
   string[] jsonArr = jsonStr.Split(new string[]{  "PROBLEM_TYPE", "DESCRIBE_TEXT", "DESCRIBE_DETAIL", "USER_ID" },StringSplitOptions.None);
fb.PROBLEM_TYPE = Convert.ToInt32(jsonArr[1].Remove(0, 3).Remove(jsonArr[1].Length - 6, 3));
            fb.DESCRIBE_TEXT = jsonArr[2].Remove(0, 3).Remove(jsonArr[2].Length - 6, 3);
            fb.DESCRIBE_DETAIL = jsonArr[3].Remove(0, 3).Remove(jsonArr[3].Length - 6, 3);
            fb.USER_ID = jsonArr[4].Remove(0, 3).Remove(jsonArr[4].Length - 5, 2);
            return fb;
        }

注意:第四步的反序列化直接用JSON.DesearilizeObject()是不可以的

文章来源:http://blog.csdn.net/wcj920946195

你可能感兴趣的:(.net,函数,编码,解决方案)