POST - 向指定的資源提交要被處理的數據
1.什么是WebAPI,詳見:http://www.cxyclub.cn/n/25123/
/// <summary>
/// 獲取post過來的數據
/// </summary>
/// <returns>返回解析的參數和值</returns>
[HttpPost]
private string GetResponseVal()
{
SortedDictionary<object, object> sorted = new SortedDictionary<object, object>();
var request = HttpContext.Current.Request;
Stream resStream = request.InputStream;
int len = (int)resStream.Length;//post數據長度
string res = string.Empty;
if (len != 0)
{
byte[] inputByts = new byte[len];//字節數據,用於存儲post數據
resStream.Read(inputByts, 0, len);//將post數據寫入byte數組中s
resStream.Close();
res = Encoding.UTF8.GetString(inputByts);//轉為UTF8編碼
}
return res;
}
