Search code examples
c#asp.netashx

asp.net ashx image simple example not compiling


I am trying to get this simple example working from http://www.dotnetperls.com/ashx.

When I add the '<%@ WebHandler Language="C#" Class="Handler" %>' first line the compiler highlights every line and gives two errors as per screenshot.

I have tried visual studio build actions of 'Content' and 'Compile' but no difference.

Screenshot



I've got to be missing something simple here!?


Solution

  • Remove '<%@ WebHandler Language="C#" Class="Handler" %>' form .ashx.cs file. This is for .ashx file.

    To view the content of .ashx file, right click on .ashx file & click on View Markup as shown the screen shot below.

    enter image description here