示例#1
0
 string GetCookieHeaderFromContext(ContextMessageProperty contextMessageProperty)
 {
     if (contextMessageProperty.Context.Count == 0)
     {
         return(HttpCookieToolbox.RemoveContextHttpCookieHeader);
     }
     else
     {
         return(HttpCookieToolbox.EncodeContextAsHttpSetCookieHeader(contextMessageProperty, this.Uri));
     }
 }
        void OnSendHttpCookies(Message message, ContextMessageProperty context, Uri requestUri)
        {
            object tmpProperty;
            HttpResponseMessageProperty property = null;

            if (message.Properties.TryGetValue(HttpResponseMessageProperty.Name, out tmpProperty))
            {
                property = tmpProperty as HttpResponseMessageProperty;
            }
            if (property == null)
            {
                property = new HttpResponseMessageProperty();
                message.Properties.Add(HttpResponseMessageProperty.Name, property);
            }
            string setCookieHeader = HttpCookieToolbox.EncodeContextAsHttpSetCookieHeader(context, requestUri);

            property.Headers.Add(HttpResponseHeader.SetCookie, setCookieHeader);
        }