title: Custom HttpHandler Error: Could not load type 'FileProtectionHandler'
body: <p>I am trying to implement a Custom HttpHandler (for the first time), I have been given a tutorial to follow but couldn't get it to work. I then found another tutorial but couldn't get that to work, they are both giving me the same error message.</p>
  
  <p>The custom handler is to protect people from downloading certain file types, although i think the error is somekind of configuration problem as I can't get the website to work at all once I add the httpHandlers to the Web.Config file.</p>
  
  <pre><code>    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
  
  Parser Error Message: Could not load type 'FileProtectionHandler'.
  
  Source Error:
  
  Line 47:         &lt;/compilation&gt;
  Line 48:         &lt;httpHandlers&gt;
  Line 49:             &lt;add verb="*" path="*.pdf" type="FileProtectionHandler"/&gt;
  Line 50:         &lt;/httpHandlers&gt;
  </code></pre>
  
  <p>If you require more code please let me know.</p>
  
  <p>Thanks for any help. J.</p>
  
  <pre><code>    &lt;%@ WebHandler Language="VB" Class="FileProtectionHandler" %&gt;
  
  Imports System
  Imports System.Web
  Imports System.Web.Security
  Imports System.IO
  Imports System.Web.SessionState
  
  Public Class FileProtectionHandler : Implements IHttpHandler
  
      Private Function SendContentTypeAndFile(ByVal context As HttpContext, ByVal strFile As [String]) As HttpContext
          context.Response.ContentType = GetContentType(strFile)
          context.Response.TransmitFile(strFile)
          context.Response.[End]()
          Return context
      End Function
  
      Private Function GetContentType(ByVal filename As String) As String
          ' used to set the encoding for the reponse stream
          Dim res As String = Nothing
          Dim fileinfo As New FileInfo(filename)
  
          If fileinfo.Exists Then
              Select Case fileinfo.Extension.Remove(0, 1).ToLower()
                  Case "pdf"
                      If True Then
                          res = "application/pdf"
                          Exit Select
                      End If
              End Select
  
              Return res
          End If
  
          Return Nothing
      End Function
  
      Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
          context.Response.ContentType = "text/plain"
          context.Response.Write("Hello World")
      End Sub
  
      Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
          Get
              Return False
          End Get
      End Property
  
  End Class
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zVGOu.gif" alt="Property Pages Img"></p>