为什么这段代码会抛出一个NullReferenceException
?
例外:
System.NullReferenceException: Object reference not set to an instance of an object.
代码:
if ((string.IsNullOrEmpty(Request.QueryString["Sno"].ToString()))
&& (string.IsNullOrEmpty(Request.QueryString["Name"].ToString())))
{
lblBookedBy.Text = "";
lblSno.Text = "";
}
else
{
lblBookedBy.Text = Request.QueryString["Name"].ToString();
lblSno.Text = Request.QueryString["Sno"].ToString();
}