I am facing one issue in Querystring when I don't have any parameters.Please find the below example. I have a below URL
1 Scenario
URL ---http://localhost/Employee/Emp/empmanagement.aspx
and I'm checking one condition and it is throwing error Request is not available
if(Request.QueryString.ToString().Contains("employeeData"))
2 Scenario
URL ---http://localhost/Employee/Emp/empmanagement.aspx?empData=employeeData
and it is working fine below
if(Request.QueryString.ToString().Contains("employeeData"))
Thanks Guys everyone's answer is correct the issue was because of my context.Qerystring was not returing.So,i declared in my aspx page and it is working fine for me.
ASPX Code
<cw:QueryString runat="server" ID="_empValue" Required="False" />
Code Behind Code
if(_empValue.Value != null && _empValue.Value.Contains("employeeData")
Countproperty likeRequest.QueryString.Count > 0?.ToString()is the culprit in the first line?QueryStringreturnsNameValueCollection, callingToStringcallsobject.ToStringand this might behave differently for it. I don't know honestly. I do not have a compiler right now.