I'm having trouble understanding how Page.Request.QueryString
and Page.Session
works. How would I assign a name
to this string
protected override void Render(HtmlTextWriter output)
{
SqlConnection sqlConnection = new SqlConnection(connectionString);
SqlCommand sqlCommand = new SqlCommand();
StringBuilder stringBuilder1 = new StringBuilder();
StringBuilder stringBuilder2 = new StringBuilder();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = "proc_UserBids";
sqlCommand.CommandTimeout = 1000;
string str = this.Page.Request.QueryString["name"] == null ? this.Page.Session["name"].ToString() : ((object)this.Page.Request.QueryString["name"]).ToString();
if (!(str == ""))
{
//Do Something
}
}
The error I'm getting is:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
string str = this.Page.Request.QueryString["name"] == null ? this.Page.Session["name"].ToString() : ((object)this.Page.Request.QueryString["name"]).ToString();