title: Can web forms and generic handlers (ashx files) share a common ancestor class (or base page)?
body: <p>If one has an ASP.net web site whose web forms all inherit from a common base page--which checks things like authentication and redirects when a session has expired, etc--is there a way to use this base class in a ashx handler? I started going down that road by inheriting the base page class in the handler and realized this might not be a recommended practice. Any thoughts on how to avoid code duplication here?</p>
  
  <p>Can this</p>
  
  <pre><code>public class FooHandler : IHttpHandler
  {
      public void ProcessRequest(HttpContext context)
      {
  </code></pre>
  
  <p>become this</p>
  
  <pre><code>public class FooHandler : BasePageClass, IHttpHandler
  {
      public void ProcessRequest(HttpContext context)
      {
  </code></pre>
  
  <p>I get the following warning, which is what made me reconsider what I was doing:</p>
  
  <blockquote>
    <p>FooHandler.ProcessRequest(System.Web.HttpContext)
    hides inherited member
    System.Web.UI.Page.ProcessRequest(System.Web.HttpContext).
    To override that implementation, add
    the override keyword. Otherwise add
    the new keyword.</p>
  </blockquote>