BAH.BOS.WebAPI.Client.CookieManager.Get C# (CSharp) Method

Get() public static method

获取Cookie。
public static Get ( string url ) : string
url string URL地址。
return string
        public static string Get(string url)
        {
            string key = GenerateKey(url);
            if (_cookieDict.Keys.Contains(key))
            {
                return _cookieDict[key];
            }
            else
            {
                return string.Empty;
            }
        }//end method

Usage Example

Beispiel #1
0
        }//end method

        /// <summary>
        /// 从进程中取出Cookie信息并赋予给HTTP请求对象。
        /// </summary>
        /// <param name="response">HTTP响应对象。</param>
        public void GetCookie(HttpWebRequest request)
        {
            //执行其他操作(非验证用户)时,读取本地Cookie
            if (!string.Equals(this._request.Operation.ServiceName, new ValidateUser().ServiceName,
                               StringComparison.OrdinalIgnoreCase))
            {
                var cookie = CookieManager.Get(this._request.Operation.RootUrl);
                request.Headers.Add("Cookie", cookie);
            } //end if
        }     //end method