2011-05-17 30 views
0

我正在使用SMS服務,通過使用get方法調用我的URL將收到的短信轉發到我的網頁。我的網頁應該以純文本的「確定」迴應,但是我不知道該怎麼做,你能給我一些建議嗎?如何響應ASP中的HTTPGET調用?

回答

1

Page_Load事件的代碼背後:

Response.Clear(); 
Response.Write("Ok"); 
Response.End(); 
1

你應該使用一個通用的處理程序(ASHX)要做到這一點,在一個通用的處理程序:

public class Handler1 : IHttpHandler 
{ 

    public void ProcessRequest(HttpContext context) 
    { 
     //your code here 
     context.Response.ContentType = "text/plain"; 
     context.Response.Write("OK"); 
    } 

    public bool IsReusable 
    { 
     get 
     { 
      return false; 
     } 
    } 
} 

之所以做這件事通用處理程序是避免aspx頁面所具有的整個頁面生命週期。

如果你已經想得起來,並在aspx頁面運行速度快,簡單地做這在類似的Page_Load:

 Response.Clear(); 
     Response.Write("OK"); 
     Response.End();