服务器端无需设置,客户端设置如下:
yixin.Service ws_user = new yixin.Service();
System.Net.CookieContainer Cookies = new System.Net.CookieContainer();
AddCookie(ref ws_user);
wsStr = ws_user.HelloWorld();
public void AddCookie(ref dmj_pic.ws_user.Service service)
{
System.Net.CookieContainer cookies = new System.Net.CookieContainer();
string cookieDomain = new Uri(service.Url).Host;
foreach (string cookieKey in HttpContext.Request.Cookies.AllKeys)
{
System.Net.Cookie netCookie = new System.Net.Cookie(cookieKey, HttpContext.Request.Cookies[cookieKey].Value, "/", cookieDomain);
netCookie.Expires = DateTime.Now.AddMinutes(5);
cookies.Add(netCookie);
}
service.CookieContainer = cookies;
}