1、創建自定義類型 2、繼承IHttpHandler接口,並實現 3、配置Web.Config文件,注冊類型 4、訪問 [csharp] public class QuickMsgSatisticsHandler : IHttpHandler { HttpContext context = null; #region IHttpHandler 成員 public void ProcessRequest(HttpContext context) { this.context = context; context.Response.ContentType = "text/plain"; Common.DataManager.QuickInsert("SMS_QuickContentSatistics", new string[1] { "ID" }, new object[1] { GetRequestID }); } public bool IsReusable { get { throw new NotImplementedException(); } } public string GetRequestID { get { return this.context.Request.Form["id"]; } } #endregion } [html] <httpHandlers> [html] <span style="white-space:pre"> </span><!--注意:verb謂詞,就是訪問方式(POST、GET等) path指示訪問路徑,type注冊類型(前面為類型名,後面為類型所在的程序集,用逗號隔開)--> <span style="white-space:pre"> </span><add verb="*" path="QuickMsgSatisticsHandler" type="ZXHomeProject.Web.SMS.QuickMsgSatisticsHandler,ZXHomeProject.Web"/> </httpHandlers> [html] $.ajax({ type: "POST", url: "QuickMsgSatisticsHandler", async : false, data: { id : $(elem).attr('msgid')}, dataType: "text", success: function(data,Status,XMLHttpRequest){ }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); } }); 優點,沒有aspx那麼笨重,速度有所提升,由於訪問局限性,安全性加強。