If you are trying to catch any space-only query string, you can always trim the query string to get rid of leading and trailing spaces, then check for its length after trimming, e.g.
string userid = " ";
if(userid.Trim().Length == 0){
Console.WriteLine("userid is empty");
}