title: How to make a base class for both Page and UserControl?
body: <p>Base classes for Page and UserControl:</p>
  
  <pre><code>public class MyWebPage : System.Web.UI.Page { }
  
  public class MyUserControl : System.Web.UI.UserControl { }
  </code></pre>
  
  <p>Helper that either of them might use:</p>
  
  <pre><code>void SetSessionValue&lt;T&gt;(string key, T value) { Session[key] = value; }
  </code></pre>
  
  <p>How can I achieve something like the following?</p>
  
  <pre><code>public class WebObject // can't inherit from both Page and UserControl { 
     protected void SetSessionValue&lt;T&gt;(string key, T value) { 
        Session[key] = value; 
     }
  }  
  
  public class MyWebPage : WebObject { }
  
  public class MyUserControl : WebObject { }
  </code></pre>
  
  <p>Update: I got excited for a second hoping I could solve it this way, but alas it doesn't compile.</p>
  
  <pre><code>public class WebObject&lt;T&gt; : T
  {
  }
  public class MyWebPage : WebObject&lt;System.Web.UI.Page&gt;
  {
  }
  </code></pre>