[C#] 纯文本查看 复制代码 /// <summary>
/// 设置Cookie
/// </summary>
/// <param name="item">Http参数</param>
private void SetCookie(HttpItem item)
{
if (!string.IsNullOrEmpty(item.Cookie)) request.Headers[HttpRequestHeader.Cookie] = item.Cookie;
//设置CookieCollection
if (item.ResultCookieType == ResultCookieType.CookieCollection)
{
request.CookieContainer = new CookieContainer();
if (item.CookieCollection != null && item.CookieCollection.Count > 0)
{
uri mUri = new uri(item.url);
request.CookieContainer.Add(mUri , item.CookieCollection);
}
}
}
就可以解决出现参数“{0}”不能是空字符串。\r\n参数名: cookie.Domain这个问题了。
|