Hi I\'m trying to set User Agent with WebRequest, but unfortunately I\'ve only found how to do it using HttpWebRequest, so here is my code and I hope you can help me to set
If you try using a HttpWebRequest instead of a basic WebRequest, then there is a specific property exposed for UserAgent.
// Create a new 'HttpWebRequest' object to the mentioned URL.
var myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
myHttpWebRequest.UserAgent=".NET Framework Test Client";
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
var myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();