string extension method - Not available through WebMethod

Posted by Peter Bridger on Stack Overflow See other posts from Stack Overflow or by Peter Bridger
Published on 2010-03-24T11:11:54Z Indexed on 2010/03/24 11:13 UTC
Read the original article Hit count: 301

Filed under:
|
|
|

I've written a simple extension method for a web project, it sits in a class file called StringExtensions.cs which contains the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Useful extensions for string
/// </summary>
static class StringExtensions
{
    /// <summary>
    /// Is string empty
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    public static bool IsEmpty(this string value)
    {
        return value.Trim().Length == 0;
    }
}

I can access this extension method from all the classes I have within the App_Code directory. However I have a web page called JSON.aspx that contains a series of [WebMethods] - within these I cannot see the extension method - I must be missing something very obvious!

© Stack Overflow or respective owner

Related posts about c#

Related posts about extension-methods