I get this warning on response.GetResponseStream()
How should I handle this?
// Get response
using (var response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
if (response != null)
{
var reader = new StreamReader(response.GetResponseStream());
var responseString = reader.ReadToEnd();
return responseString;
}
}
For clarity based on some answers misinterpreting:
This line is not where the warning is occurring:
using (var response = request.GetResponse() as HttpWebResponse)
This line is where the warning is occurring:
var reader = new StreamReader(response.GetResponseStream());
I suspect
StreamReaderconstructor’s parameter has anotnullattribute. Try the following: