Just add the using at the beginning and the [WebMethod] decorator to the static method to be called in the aspx page:
using System.Web.Services;
public partial class MyPage : System.Web.UI.Page
{
[WebMethod]
public static int GetRandomNumberLessThan(int limit)
{
var r = ...