string comment;
    string softname;       comment = HttpUtility.UrlDecode(context.Request.QueryString["comment"].ToString());
        softname = HttpUtility.UrlDecode(context.Request.QueryString["softname"].ToString());如果URL是http://192.168.0.241/comment.ashx?comment=XXX&softname=yyy 这样没问题
但是如果是http://192.168.0.241/comment.ashx?comment=XXX 程序就会报错难道querystring 在获取值之前非要判断一下是否存在吗 ?
为什么不是如果不存在就不赋值?

解决方案 »

  1.   

    肯定会报错啊!如果你想要判断是否为空可以用下面的方法:if(!string.IsNullOrEmpty(Request.QueryString["comment"]))
    {
     //不为空
    }
    else
    {
    //为空!
    }
    //这样就不会报错了!
      

  2.   

    comment = HttpUtility.UrlDecode(context.Request.QueryString["comment"].ToString());
            softname = HttpUtility.UrlDecode(context.Request.QueryString["softname"].ToString());=》comment = HttpUtility.UrlDecode(context.Request.QueryString["comment"]??"");
            softname = HttpUtility.UrlDecode(context.Request.QueryString["softname"]??"");
      

  3.   

    HttpUtility.UrlDecode(context.Request.QueryString["comment"])
    这样就行了,谁让你没事就ToString()来着?没有就是null
      

  4.   

    你这个编译能通过?
    建议学学java的方法 ,虽然不怎么好看Request.QueryString["comment"]+""