Search code examples
c#web-servicessoapasmx

Sharing Common Methods for .asmx.cs Files


I am trying to share a common method between a bunch of legacy .asmx files. The files are just 'helper' type methods, so I don't feel the need to put them into their own project (although if that is the solution, so be it). Right now one of the methods is in a static class and looks like this:

public static class WebServiceHelper
{
    public static string GetUsername(ref int statusCode, string absoluteUri)
    {
        ...
    }
}

However, this class is not visible to the .asmx.cs files. I have tried putting the files in their own project (not ideal), but the project's namespaces also seem 'invisible' to the web service project. This worked previously using an App_Code folder, but I need to remove this as I am implementing a static weaver for method timing. I have a very hackish solution that seems more like a side effect. If I place the 'helper' classes at the bottom of any of the .asmx.cs files, they become available to all of the .asmx.cs files.

Any suggestions?


Solution

  • The issue was with the project file. I created a new ASMX project and the problem went away. No App_Code project was created (which made more sense) for this project, so the previous developer most likely used a website project.