Winform下使用HttpWebResponse.Headers.Get("Set-Cookie")得到的值是es%3D047de843fd334b403beff9bfb6bd33bf%26ev%3Dv0%26es2%3D581483de5369e77f618dbd0e5c878aecCookies是
es=047de843fd334b403beff9bfb6bd33bf&ev=v0&es2=581483de5369e77f618dbd0e5c878aec怎么操作把得到的Set-Cookie的值转换下呢

解决方案 »

  1.   

    不明
    Set-Cookie的值转换下,怎么转换,转换成什么样?
      

  2.   


    HttpWebResponse.Headers.Get("Set-Cookie")是经过编码的,还原成编码前的状态
    类似webform里的Server.UrlDecode和Server.UrlEncode
      

  3.   

    CookieCollection   cc   =new   CookieCollection(); 
    string   s   =   ""; 
    Regex   re   =   new   Regex( "([^;,]+)=([^;,]+);Domain=([^;,]+);Path=([^;,]+) ",   RegexOptions.IgnoreCase); 
    foreach   (Match   m   in   re.Matches(s)) 
    {Cookie   c   =   new   Cookie(m.Groups[1].Value,   m.Groups[2].Value,m.Groups[3].Value,m.Groups[3].Value); 
    cc.Add(c); 
    }
      

  4.   


    tgc=TGT-MTYzMjIwNTYzMA==-1292461791-B7E3A018B85ADAF11CF5C4BD29ADAC5F; domain=login.sina.com.cn; path=/; Httponly,SUE=es%3Dd2974e3a54cc6e462d1b972c6e240f6e%26ev%3Dv0%26es2%3D8ea370369e3e4c820b5acc123627a078;path=/;domain=.sina.com.cn;Httponly,SUP=cv%3D1%26bt%3D1292461791%26et%3D1292548191%26lt%3D1%26uid%3D1632205630%26user%3Dzwh870419%2540163.com%26ag%3D4%26name%3Dzwh870419%2540163.com%26nick%3Dvincent%26sex%3D%26ps%3D0%26email%3D%26dob%3D%26ln%3Dzwh870419%2540163.com;path=/;domain=.sina.com.cn,ALC=cv%3D1.0%26es%3D100f68295eb66b83ca096da79c5370de%26bt%3D1292461791%26et%3D1293066591%26uid%3D1632205630;expires=Thu, 23 Dec 2010 01:09:51 GMT;path=/;domain=login.sina.com.cn;Httponly,ALF=1293066591;expires=Thu, 23 Dec 2010 01:09:51 GMT;path=/;domain=.sina.com.cn,SUR=uid%3D1632205630%26user%3Dzwh870419%2540163.com%26nick%3Dvincent%26email%3D%26dob%3D%26ag%3D4%26sex%3D%26ssl%3D0;expires=Thu, 23 Dec 2010 01:09:51 GMT;path=/;domain=.sina.com.cn
    匹配不了那个正则
      

  5.   

    我晕  %3d  就是 =    这是url 传输的时候   一种编码转换   c#  有个类你可以转换一下的..我倒
      

  6.   


      string viewState = System.Web.HttpUtility.UrlEncode("/wEPDwUKMTA2MTA3Njg5NA9kFgICCQ9kFgJmD2QWAgIFD2QWAmYPZBYCZg8PFgIeBE1vZGULKiVTeXN0ZW0uV2ViLlVJLldlYkNvbnRyb2xzLlRleHRCb3hNb2RlARYCHgVzdHlsZQUYaGVpZ2h0OjE4MHB4O3dpZHRoOjEwMCU7ZGRpl2NuIb2XmIUODhEniCtEXExdOA==");
    System.Web.HttpUtility.UrlEncode
      

  7.   

    string s="tgc=TGT-MTYzMjIwNTYzMA==-1292461791-B7E3A018B85ADAF11CF5C4BD29ADAC5F; domain=login.sina.com.cn; path=/; Httponly,SUE=es%3Dd2974e3a54cc6e462d1b972c6e240f6e%26ev%3Dv0%26es2%3D8ea370369e3e4c820b5acc123627a078;path=/;domain=.sina.com.cn;Httponly,SUP=cv%3D1%26bt%3D1292461791%26et%3D1292548191%26lt%3D1%26uid%3D1632205630%26user%3Dzwh870419%2540163.com%26ag%3D4%26name%3Dzwh870419%2540163.com%26nick%3Dvincent%26sex%3D%26ps%3D0%26email%3D%26dob%3D%26ln%3Dzwh870419%2540163.com;path=/;domain=.sina.com.cn,ALC=cv%3D1.0%26es%3D100f68295eb66b83ca096da79c5370de%26bt%3D1292461791%26et%3D1293066591%26uid%3D1632205630;expires=Thu, 23 Dec 2010 01:09:51 GMT;path=/;domain=login.sina.com.cn;Httponly,ALF=1293066591;expires=Thu, 23 Dec 2010 01:09:51 GMT;path=/;domain=.sina.com.cn,SUR=uid%3D1632205630%26user%3Dzwh870419%2540163.com%26nick%3Dvincent%26email%3D%26dob%3D%26ag%3D4%26sex%3D%26ssl%3D0;expires=Thu, 23 Dec 2010 01:09:51 GMT;path=/;domain=.sina.com.cn"
    CookieCollection cc =new CookieCollection(); 
    Regex re = new Regex( "([^;,]+)=([^;,]+);Domain=([^;,]+);Path=([^;,]+) ", RegexOptions.IgnoreCase); 
    foreach (Match m in re.Matches(s)) 
    {Cookie c = new Cookie(m.Groups[1].Value, m.Groups[2].Value,m.Groups[3].Value,m.Groups[3].Value); 
    cc.Add(c); 
    }匹配不了那个正则啊?怎么改改就可以了?正则不会