richard
richard

Reputation: 12508

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?

Upvotes: 5

Views: 14379

Answers (6)

KWallace
KWallace

Reputation: 1698

In Visual Studio, click on your generic handler in Solution Explorer, then press F4 for "Properties". Make sure your build action is "compile", not just "content".

Upvotes: 0

AJ AJ
AJ AJ

Reputation: 325

I renamed my handler through the solution explorer.

VS2017 suggested changeing the name only in .cs file, and left the class attribute in the ashx file incorrect.

Upvotes: 0

Jeff Yates
Jeff Yates

Reputation: 1093

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

Upvotes: 5

Shadi Alnamrouti
Shadi Alnamrouti

Reputation: 13268

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" %>

Upvotes: 13

Nathan Koop
Nathan Koop

Reputation: 25197

I had an issue with the naming of the namespace, so I had to edit the example.ashx file (not the example.ashx.cs) and change the namespace name there.

Upvotes: 1

Sagar S.
Sagar S.

Reputation: 193

Add below tag

<%@ Assembly  Name="YourNameSpace.YourHandlerClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=90e3045b123af1c3" %>

above your WebHandler tag

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

Upvotes: 1

Related Questions