使用 asp.net 中的 request.querystring 重定向到另一个 asp.net 页面
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"]
它returns 无效。因此,当您在 null 上调用 ToString() 时,它会引发异常。
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"]
它returns 无效。因此,当您在 null 上调用 ToString() 时,它会引发异常。