0

I have created a Generic Handler using Studio 2012. I'm able to call it on my local machine. When I move it up to my IIS 8.5 server I'm getting a message saying "An Internal Server Error has occurred" The event viewer lists the error code as 1310.

To deploy I'm going to my project folder and copying TestHandler.ashx and TestHandler.ashx.cs and placing them in the root folder. This folder contains all of the files that run the DotNetNuke 8.0 CMS system. It is not clear to me if DotNetNuke is interfering, or there are additional files to copy, but I've read there is no need to register an ashx with web.config.

I have not added custom code to the TestHandler yet.

public void ProcessRequest(HttpContext context)
{
    context.Response.ContentType = "text/plain";
    context.Response.Write("Hello World");
}
VDWWD
  • 35,079
  • 22
  • 62
  • 79
Martin Muldoon
  • 3,388
  • 4
  • 24
  • 55

1 Answers1

1

Because you have 2 files for the Handler (.ashx and ashx.cs) you probably created it in a Project. Did you compile it and copied the .dll file into the /bin directory of the DotNetNuke installation? If not what is the exact error message in the Event Viewer?

But this snippet does not require 2 files, just save it as an .ashx file and it will work.

<%@ WebHandler Language="C#" Class="Handler1" %>

using System;
using System.Web;

public class Handler1 : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}
VDWWD
  • 35,079
  • 22
  • 62
  • 79
  • I copied the dll to /bin and it works now.. This does lead to another question though.. I've read in several places that a Generic Handler will compile in real time whereas an ASP.Net Handler requires the dll to be copied and referenced in web.config. Any idea why my ashx isn't compiling on the server? Thanks! Martin. – Martin Muldoon Aug 29 '16 at 15:57
  • Not sure myself, maybe the ashx must be a single page (like my snippet). That is compiled at runtime because... it works. See http://stackoverflow.com/questions/25510189/how-to-dynamically-compile-a-ashx-file for a similar question – VDWWD Aug 29 '16 at 17:10