locked
Extend WebClient? Inheritance security rules RRS feed

  • Question

  • I would like to extend WebClient to include cookies.

        public class WebClientWithCookies : WebClient
        {
            private readonly CookieContainer _cookies = new CookieContainer();
            public CookieContainer Cookies { get { return _cookies; } }
    
            [SecuritySafeCritical]
            public WebClientWithCookies()
                : base()
            {
            }
    
            protected override WebRequest GetWebRequest(Uri address)
            {
                WebRequest request = base.GetWebRequest(address);
    
                if (request.GetType() == typeof(HttpWebRequest))
                    ((HttpWebRequest)request).CookieContainer = _cookies;
    
                return request;
    
            }
        }


     

    When I construct it I get inheritance security rules violated while overriding member: 'Tools.WebClientWithCookies..ctor()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

     
    Thursday, April 28, 2011 1:25 AM

Answers

All replies