Question

Question:

How does one deploy a HttpHandler in asp.net 2.0?

Updated Http Handler code (Inside App_Code):

namespace Samples
{
    public class SampleHandler : IHttpHandler
    {    
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

Updated Web.Config file

  <system.web>
    <httpHandlers>
      <add verb="*" type="Samples.SampleHandler" path="*.js"/>
    </httpHandlers>
  </system.web>

aspx page

<script type="text/javascript" src="scripts/sample.js"></script>

as you see every javascript request must be routed to the http handler but it doesn't.

Was it helpful?

Solution

You may take a look at the following guide.

OTHER TIPS

To get asp.net to respond to requests for filetypes that are not asp.net specific ones you need to ensure that a wildcard mapping has been configured (first part of article). This ensures that IIS passes requests for files ending in .js to asp.net so your custom handler will be called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top