我沒有得到一個錯誤,而是一個「無效登錄」消息,這讓我覺得形式實際上使POST請求代替。這裏是一個Get Request示例:
using System;
using System.Net;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
//do get request
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://sms-om.com/smspro/sendsms.php?user=HatemSalem");
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
//read the data and print it
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
}
while (count > 0);
Response.Write(sb.ToString());
}
}
祝你好運!
你什麼錯誤呢? –
沒有錯誤。但是Http請求似乎不起作用。該代碼有什麼問題? – Aan
那麼請求值中的數據是什麼?它可能不爲空... – Phil