[C#] 纯文本查看 复制代码
/// <summary>
/// 根据字符生成Cookie和精简串,将排除path,expires,domain以及重复项
/// </summary>
/// <param name="strcookie">Cookie字符串</param>
/// <returns>精简串</returns>
public static string GetSmallCookie(string strcookie)
精简化Cookie的方法大家以后就省去了很多麻烦[C#] 纯文本查看 复制代码
//获取精简字符串Cookie
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://www.sufeinet.com",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
//ResultCookieType = ResultCookieType.String //默认值可以不写
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请求的Cookie
string cookie = result.Cookie;
//输出
Response.Write(cookie + "<br/><br/>");
//产获取精简化的Cookie,将自动去掉\r\n换行符号,path,expires,domain,去重复等多余选项
cookie = HttpHelper.GetSmallCookie(cookie);
//输出
Response.Write(cookie);