http请求
作者:互联网
HttpWebRequest webRequest = null;
StreamReader responseReader = null;
try {
//ashx Url
string getGscUserUrl = "";
//加入参数,用于更新请求
//string urlHandler = getGscUserUrl + "?id=" + Guid.NewGuid();
webRequest = (HttpWebRequest)HttpWebRequest.Create(getGscUserUrl);
webRequest.Timeout = 3000;//3秒超时
//调用ashx,并取值
responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
string currentUserGulid = responseReader.ReadToEnd();
return currentUserGulid.Trim();
} catch {
return "";
} finally {
responseReader.Close();
responseReader.Dispose();
}
标签:http,请求,webRequest,HttpWebRequest,return,getGscUserUrl,responseReader,string 来源: https://www.cnblogs.com/siyisiyue/p/15161377.html