ASHX file Parser error - failed to create type

I have a sample IIS install application from a vendor that I am testing to generate barcodes.

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

Server error in application "/ BarcodeSample".

Parser Error: An error occurred while parsing a resource required to service this request. Review the following parsing error details and modify the source file accordingly.

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 Info: 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?

+3


source to share


5 answers


Check the fully qualified class name starting with the namespace (if used). I had the same problem and it was fixed after changing the class name as follows:

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

      



instead of this:

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

      

+7


source


A simple workaround I found works:



  • Place your .ashx.cs code after the first line of your .ashx file
  • Remove CodeBehind attribute on first line of .ashx file
  • Delete code behind file
+1


source


Add tag below

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

      

above the WebHandler tag

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

      

0


source


I had a problem with the namespace name, so I had to edit the file example.ashx

(not example.ashx.cs

) and change the namespace name there.

0


source


I renamed my handler via the solution explorer.

VS2017 suggested changing the name only in the .cs file and left the wrong class attribute in the ashx file.

0


source







All Articles