简体   繁体   中英

redirecting to another asp.net page using request.querystring in asp.net

int ob=0;

protected void Button1_Click(object sender, EventArgs e)

{
    ob = Convert.ToInt32(Request.QueryString["value"].ToString());

    if (RadioButton1.Checked == true)
    {
        ob = ob + 1;
    }
    else
    {
        ob = ob + 0;
    }
    Response.Redirect("result.aspx?value = " + ob);
}

exception:- System.NullReferenceException: 'Object reference not set to an instance of an object.'

System.Collections.Specialized.NameValueCollection.this[string].get returned null.

Request.QueryString["value"]

It returns null. So when you call ToString() on null it rises exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM