title: Http Handler is working in iis express and not working in iis server
body: <p>I am going to implement HttpHandler in order to allow file downloading from my site based on session values. If the session exist allow the user to download the file otherwise redirect to index page which is the login page for the site. My code is working perfect in iis express when I run my website in iis server the handler is not working. </p>
  
  <p>For IIS express the web.config file has the following sections which I have added. The below configuration is working in iis express.</p>
  
  <pre><code>&lt;system.web&gt;
  
  &lt;httpHandlers&gt;
  
    &lt;add verb="*" path="*.pdf" type="QDMS.FileHandler" /&gt;
  Same add tag for all the files to restrict downloading without session.
  
  &lt;/httpHandlers&gt;
  
  &lt;/system.web&gt;
  </code></pre>
  
  <p>The configurations for IIS servers which is not working is below.</p>
  
  <pre><code>&lt;system.webServer&gt;
  
  &lt;handlers&gt;
    &lt;add name="Files" path="*.pdf,*.doc,*.docx,*.rar,*.zip,*.ppt,*.pptx,*.jpg,*.png,*.bmp,*.gif,*.html,*.htm,*.pps" verb="*" type="QDMS.FileHandler" resourceType="Unspecified" requireAccess="script" /&gt;    
  &lt;/handlers&gt;
  
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>My File handler is below</p>
  
  <pre><code>using System;
  using System.Web;
  using System.Web.SessionState;
  using QDMS.Old_App_Code;
  
  namespace QDMS
  {
  public class FileHandler : IHttpHandler, IReadOnlySessionState
  {
  public bool IsReusable
  {
  get { return true; }
  }
  public void ProcessRequest(HttpContext context)
  {
  if (!CheckWetherTheRequestForFileExistOrNot(context)) return;
  if (CheckUsersForFileDownloading(context))
  context.Response.Redirect("~/index.aspx");
  else
  {
  var rawURL = context.Request.RawUrl;
  var dotIndex = rawURL.LastIndexOf(".", System.StringComparison.Ordinal);
  var ext = rawURL.Substring(dotIndex);
  context.Response.ClearContent();
  context.Response.ClearHeaders();
  context.Response.ContentType = MIMEEType.Get(ext);
  context.Response.AddHeader("Content-Disposition", "attachment");
  context.Response.WriteFile(rawURL);
  context.Response.Flush();
  }  
  }
  public bool CheckWetherTheRequestForFileExistOrNot(HttpContext context)
  {
  string url = context.Request.RawUrl.ToLower().Trim();
  if (url.Contains(".pdf") || url.Contains(".xls") || url.Contains(".xlsx") || url.Contains(".jpg") ||
              url.Contains(".bmp") || url.Contains(".rar") || url.Contains(".doc") || url.Contains(".docx") ||
              url.Contains(".png") || url.Contains(".gif") || url.Contains(".pptx") || url.Contains(".zip") ||
              url.Contains(".ppt") || url.Contains(".pps") || url.Contains(".htm") || url.Contains(".html"))
  return true;
  else
  return false;
  }
  public bool CheckUsersForFileDownloading(HttpContext context)
  {
  return (context.Session["FrontHiddenID"] == null) &amp;&amp; (context.Session["HiddenID"] == null);
  }
  }
  }
  </code></pre>
  
  <p>I am sure that in the  section in the web.config file is not correct that is why it is not working. So I need suggestions to rectify my handlers section in web.config file.
  Any advice and help regarding this issue will be higly appreciated</p>