1
Answer

overriding the same method without code duplication

meat meat

meat meat

13y
10.7k
1
Hi !

I have several web references in my project .
I created a new class that inherit from those web reference class and I override GetWebResponse from each of those web reference class.
For instance
public class UserServiceProxy : .UserService
{
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion = HttpVersion.Version10;
return webRequest;
}
}
How do it prevent code repetition like this in every proxy class that inherit from the web reference

Thanks
Answers (1)