Response.Redirect("ImageCode.aspx?strText = "+strText+"&strSize = "+strSize+"&strColor = "+strColor+"&imgWith = "+imgWith+"&imgHeight = "+imgHeight+"");
            //Image1.Visible = true;
aspx.cs页面            string strText = Request.QueryString["strText"].ToString();
            string strSize = Request.QueryString["strSize"].ToString();
            string strColor = Request.QueryString["strColor"].ToString();
            string imgWith = Request.QueryString["imgWith"].ToString();
            string imgHeight = Request.QueryString["imgHeight"].ToString();为什么会报错?为将对象引用到实例!

解决方案 »

  1.   

    Response.Redirect("ImageCode.aspx?strText = "+Server.UrlEncode(strText)+"&strSize = "+Server.UrlEncode(strSize)+"&strColor = "+Server.UrlEncode(strColor)+"&imgWith = "+imgWith+"&imgHeight = "+imgHeight+"");
      

  2.   

    你应该先判断
    if(String.IsNullOrEmpty(Request.QueryString["strText"])!=false)
    {
     strText = Request.QueryString["strText"].ToString();
    }
      

  3.   

    string strText = Request.QueryString["strText"]==null?"":Request.QueryString["strText"].ToString();
    string strSize = Request.QueryString["strSize"]==null?"":Request.QueryString["strSize"].ToString();
    string strColor = Request.QueryString["strColor"]==null?"":Request.QueryString["strColor"].ToString();
    ...
    Response.Redirect("ImageCode.aspx?strText = "+strText+"&strSize = "+strSize+"&strColor = "+strColor+"&imgWith = "+imgWith+"&imgHeight = "+imgHeight+"");
            
      

  4.   

    应该是 传入url中的自定义信息不符合 URL编码 !