我基本知道是因为Ex.Message里面有一些特殊字符造成的,
有没有什么比较通用或者优化的解决方法?那些特殊字符应该是‘\’,‘'’之类的

解决方案 »

  1.   

    先把异常里的特殊字符替换掉呢?
    public static string Encode(String s)
    {
    String tempstr="";
    tempstr+=s.Replace("<","&lt;");
    tempstr=tempstr.Replace(">","&gt;");
    tempstr=tempstr.Replace(" ","&nbsp;");
    tempstr=tempstr.Replace("\'","\"");
    return tempstr;
    }
    public static string Decode(String s)
    {
    String tempstr="";
    tempstr+=s.Replace("&lt;","<");
    tempstr=tempstr.Replace("&gt;",">");
    tempstr=tempstr.Replace("&nbsp;"," ");
    tempstr=tempstr.Replace("\"","\'");
    return tempstr;
    }
      

  2.   

    to 楼上的:
    是js,与html无关