/// <summary>
/// 参数类的get或post请求接收所有参数
/// </summary>
/// <param name="reMsg"></param>
/// <param name="RequestType"></param>
/// <param name="?"></param>
/// <returns></returns>
public Dictionary<string, string> GetAllPara(ref string ReMsg, ref string RequestType, ref string otype)
{
Dictionary<string, string> dicRequestData = new Dictionary<string, string>();
ReMsg += "数据传送方式:";
string guid = Guid.NewGuid().ToString();
if (context.Request.RequestType.ToUpper() == "POST")
{
RequestType = "POST";
ReMsg += RequestType + "\r\n参数分别是:\r\n";
SortedList table = sParam();
//Hashtable table = hParam();
if (table != null)
{
foreach (DictionaryEntry De in table)
{
ReMsg += "参数名:" + De.Key + " 值:" + De.Value + "\r\n";
if (otype == "" && De.Key.ToString().ToUpper() == "otype".ToUpper())
{
otype = De.Value.ToString().ToUpper();
}
dicRequestData.Add(De.Key.ToString().ToUpper(), De.Value.ToString());
}
}
else
{
ReMsg += "没有传递任何参数过来";
}
}
else
{
RequestType = "GET";
ReMsg += RequestType + "\r\n参数分别是:\r\n";
NameValueCollection nvc = GETInput();
if (nvc.Count != 0)
{
for (int i = 0; i < nvc.Count; i++)
{
if (otype == "" && nvc.GetKey(i).ToUpper() == "otype".ToUpper())
{
otype = nvc.GetValues(i)[0].ToUpper();
}
ReMsg += "参数名:" + nvc.GetKey(i) + " 值:" + nvc.GetValues(i)[0] + "\r\n";
dicRequestData.Add(nvc.GetKey(i).ToString().ToUpper(), nvc.GetValues(i)[0]);
}
}
else
{
ReMsg += "没有传递任何参数过来";
}
}
ReMsg += "参数名:请求IP 值:" + context.Request.UserHostAddress + "\r\n";
otype = otype.ToUpper();
return dicRequestData;
}
C#-HTTP-参数接收(包括URL参数和Post表单)
最新推荐文章于 2024-05-18 16:36:40 发布