string extension method - Not available through WebMethod
- by Peter Bridger
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!