diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index d6ae6d7146e80..78142ca5759bb 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -208,8 +208,8 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params HttpClient = newClient; Type type = this.GetType(); //setting userAgentBelow is removed because now the client can set it using SetUserAgent method - /* HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, - GetClientVersion()));*/ + HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName, + GetClientVersion())); } //A mehtod to set user agent @@ -217,6 +217,10 @@ public bool SetUserAgent(string productName) { if(!_disposed && HttpClient != null) { + /// + /// Dispose the the old useragent. + /// + HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, GetClientVersion())); // returns true if the userAgent was added return true; @@ -231,6 +235,10 @@ public bool SetUserAgent(string productName,string version) { if(!_disposed && HttpClient != null) { + /// + /// Dispose the the old useragent. + /// + HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version); // returns true if the userAgent was added return true;