Search code examples
asp.nethandler

I can't call a method that's in the App_Code folder within the ashx file


The problem that I have (don't know what happened that cause it - it worked fine before):

I can't call a function in the App_Code folder from an ashx file (from a regular code behind C# file, it's working fine).

The class name is SendMail and the method name is SendEmail

The handler file:

enter image description here

Class set to 'compile'

enter image description here

The method

enter image description here

What can cause that?


Solution

  • You have two classes named SendMail, which is confusing both the compiler and you. I highly recommend more meaningful naming of your components.

    If your classes are in two different namespaces, you can reference the target class explicitly by using its entire namespace. Something like:

    YourNamespace.SendMail
    

    Then you can call the method:

    bool mailSent = YourNamespace.SendMail.SendEmail(firstName, lastName, ...