zoukankan      html  css  js  c++  java
  • WCF Cookie处理

    wcf操作cookie看似很简单,如果不对Wcf研究一把还是很难的,基本上无从下手。

    这里上一图

    上面的结果,岂止是坑爹,简直就是坑爹!!!

    废话不多说,直接上代码:

    cookie读取

    1             var requestProperties = OperationContext.Current.IncomingMessageProperties;
    2 
    3             var hrp = requestProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
    4 
    5             var cookie = hrp.Headers[System.Net.HttpRequestHeader.Cookie];

    cookie写入

    1             var responseProperties = OperationContext.Current.OutgoingMessageProperties;
    2 
    3             var httpResponseProperties = new HttpResponseMessageProperty();
    4 
    5             httpResponseProperties.Headers.Add(HttpResponseHeader.SetCookie, "name=yswenli");
    6 
    7             responseProperties.Add(HttpResponseMessageProperty.Name, httpResponseProperties);

    原理就是wcf 的 restful 是用[webget]或[webinvoke]针对operation的绑定,所以要使用web相关的就可能到OperationContext 里面去找~

    转载请注明本文地址:http://www.cnblogs.com/yswenli/p/7274549.html

  • 相关阅读:
    lambda表达式
    You can't specify target table 't_mail_marketing' for update in FROM clause
    从对象list中获取对象属性list
    枚举缓存
    Solr语法
    通过Telnet查询注册服务
    日志查询
    Maven 屏蔽静态文件
    抽奖
    随机码生成方法
  • 原文地址:https://www.cnblogs.com/yswenli/p/7274549.html
Copyright © 2011-2022 走看看