像调用方法一样调用aspnetwebservice

本文关键字:调用 一样 aspnetwebservice 方法 | 更新日期: 2023-09-27 18:13:49

我让我的一些ajax可见的谷歌。要做到这一点,我必须提供基于查询字符串(转义片段)我的内容的html快照。问题是,我的一些html是由webservices调用返回的。

我有一个类,叫做Site.ajax。_search,里面有webmethods,比如:
[WebMethod(EnableSession = true)]
public string ReadSearch(string nm_what, string nm_where, int pageindex)
{
}

像调用方法一样调用aspnetwebservice

是的,这很好,我也会把它设置为静态的:

[WebMethod(EnableSession = true)]
public static string ReadSearch(string nm_what, string nm_where, int pageindex)
{
}
//from another page
protected void Page_Load(object sender, EventArgs e)
{ 
    //example
    string s = Search.ReadSearch("this","here",2); //add namespace and references needed
}

为什么ASP。. NET AJAX页面方法必须是静态的吗?