【发布时间】:2013-11-01 17:12:12
【问题描述】:
如何在不加载完整内容的情况下获取请求的响应类型?、 我只对获取响应的 ContentType 感兴趣。
下面是我正在做的代码。
public static bool OutPutFormat(string url, string type)
{
var request = (HttpWebRequest)WebRequest.Create(url);
using (var response = (HttpWebResponse)request.GetResponse())
{
string _type = "application/" + type;
string _apiType = response.ContentType.Split(';')[0].ToString();
if (_apiType == _type)
{
return true;
}
}
return false;
}
【问题讨论】:
标签: c# content-type