silverlight 4,获取html cookie [英] silverlight 4, getting html cookies

查看:95
本文介绍了silverlight 4,获取html cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Fiddler 2中,Raw数据显示以下Cookie:

  __ utma_a2a = 7477768302.1349257957.1317701031.1318843147.1318844585.14; 
会话=3YZAdX / xEuKVpYZWKBmcbC2S1YE =
_flashes = KGxwMQooUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKdHAyCmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBp
bicKdHAzCmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKdHA0CmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKd
HA1CmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKdHA2CmEoUydtZXNzYWdlJwpwNwpTJ0xvZ2dlZCBpbicKcD
gKdHA5CmEu&放大器;
_fresh = STAxCi4 =安培; _id = UycwO0BAXHhlY1x4MTlceDA3LSBceGI1XHhlOVx4OWRceGQ3MFx4MTVceGIyJwpwMQou&安培;
user_id = VjMKLg ==

(实际上,分号之间没有空格; / p>

但在Silverlight客户端

  string [] cookies = System.Windows .Browser.HtmlPage.Document.Cookies.Split(';'); 

只获取1个分号。所有开始的会话不在那里。

解决方案

在Fiddler中再次观察HTTP会话,而不是包含 Set-Cookie 头设置会话 cookie。



我怀疑cookie会有httpOnly指令,这意味着它不能被客户端代码检索,它将被标准的API暴露cookie脚本(或在这种情况下,Silverlight)代码。


In Fiddler 2, Raw data shows the following cookies:

__utma_a2a=7477768302.1349257957.1317701031.1318843147.1318844585.14;   
 session="3YZAdX/xEuKVpYZWKBmcbC2S1YE=?
_flashes=KGxwMQooUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKdHAyCmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBp
bicKdHAzCmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKdHA0CmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKd
HA1CmEoUydtZXNzYWdlJwpTJ0xvZ2dlZCBpbicKdHA2CmEoUydtZXNzYWdlJwpwNwpTJ0xvZ2dlZCBpbicKcD
gKdHA5CmEu&
_fresh=STAxCi4=&_id=UycwO0BAXHhlY1x4MTlceDA3LSBceGI1XHhlOVx4OWRceGQ3MFx4MTVceGIyJwpwMQou&
user_id=VjMKLg=="

(actually no space in between except after semicolon;)

But in Silverlight client

string[] cookies = System.Windows.Browser.HtmlPage.Document.Cookies.Split(';');

gets only 1 entry to the semicolon. All starting 'session' isn't in there. How can I get whole cookie string?

解决方案

Observe the HTTP conversation again in Fiddler and take not of the earlier response that contains the Set-Cookie header that sets the session cookie in the first place.

I suspect that cookie will have the "httpOnly" directive which means that it can not be retrieved by client code, it will be excluded by the standard APIs that expose cookies to script (or in this case Silverlight) code.

这篇关于silverlight 4,获取html cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆