Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASHX file Parser error - could not create type

I got a sample application to install on IIS from a vendor that I am testing for making barcodes.

The aspx pages work fine, but when the aspx page calls the ashx page, I get the error below:

Server Error in '/BarcodeSample' Application.

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type 'TECIT.OnlineBarcodes.BarcodeHandler'.

Source Error:

Line 1: <%@ WebHandler Language="C#" CodeBehind="BarcodeHandler.ashx.cs" Class="TECIT.OnlineBarcodes.BarcodeHandler" %>

Source File: /BarcodeSample/BarcodeHandler.ashx Line: 1

-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.3634; ASP.NET Version:2.0.50727.3634

Why is this happening? How can I get this ashx file to work?

like image 282
richard Avatar asked Feb 11 '13 22:02

richard


People also ask

What is ASHX file in C#?

What is an ASHX file? An ASHX file is a webpage that is used by the ASP.NET HTTP Handler to serve user with the pages that are referenced inside this file. The ASP.NET HTTP Handler processes the incoming request, references the pages from the . ashx file, and sends back the compiled page back to the user's browser.

How do I install an ASHX file?

For adding ashx file follow below steps. Right click on Project. Select Add from the menu. In Add New Item dialog window select Generic Handler and click on Add.

How do you run ASHX?

An ashx file is a just a generic HTTP handler, so the easiest way to get this working is to create a new Web Site in the File menu, and just add the Handler. ashx file to the website root directory. Then, just run the site (F5) and browse to " YourSite/Handler. ashx ".


2 Answers

Check the full name of the class starting from the namespace (if used). I had the same issue and it was fixed after changing the class name like this:

<%@ WebHandler Language="C#" Class="Namespace.ClassName" %>

instead of this:

<%@ WebHandler Language="C#" Class="ClassName" %>
like image 69
Shadi Namrouti Avatar answered Sep 28 '22 03:09

Shadi Namrouti


A simple workaround that I found works:

  • Put the .ashx.cs code after the first line of the .ashx file
  • Remove the CodeBehind attribute on the first line of the .ashx file
  • Remove the Code behind file
like image 25
Jeff Yates Avatar answered Sep 28 '22 02:09

Jeff Yates