servicestack,silverlight-5.0,Cookies,servicestack,Silverlight 5.0" /> servicestack,silverlight-5.0,Cookies,servicestack,Silverlight 5.0" />

Cookies 授权cookie未在JsonServiceClient请求上持久化

Cookies 授权cookie未在JsonServiceClient请求上持久化,cookies,servicestack,silverlight-5.0,Cookies,servicestack,Silverlight 5.0,我刚刚将Silverlight应用程序中的ServiceStack程序集从4.0.9升级到4.0.20 新版本似乎没有保留cookie。JsonServiceClient的创建如下所示: return new JsonServiceClient(this._address.ToString()) { StoreCookies = true, ShareCookiesWithBrowser = false }; HTTP/1.1 200 OK Cache-Control: no-store,mu

我刚刚将Silverlight应用程序中的ServiceStack程序集从4.0.9升级到4.0.20

新版本似乎没有保留cookie。JsonServiceClient的创建如下所示:

return new JsonServiceClient(this._address.ToString()) { StoreCookies = true, ShareCookiesWithBrowser = false };
HTTP/1.1 200 OK
Cache-Control: no-store,must-revalidate,no-cache,max-age=0
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Vary: Accept
Server: Microsoft-HTTPAPI/2.0
Set-Cookie: ss-id=5cwF1pftMI0R2LphJMjr;path=/
Set-Cookie: ss-pid=KnLVQCQtQe9pvBilJBXU;path=/;expires=Sun, 14 May 2034 13:34:03 GMT
Set-Cookie: X-UAId=;path=/;expires=Sun, 14 May 2034 13:34:03 GMT
X-Served-By: XY Server/2014.1.0 (rev 0) RC1 - XYServer
X-Powered-By: ServiceStack/4,020 Win32NT/.NET
Date: Wed, 14 May 2014 13:34:03 GMT
(我是否使用浏览器指定ShareCookies并不重要)

当我与Fiddler进行核对时,我对/auth的初始POST请求的响应如下:

return new JsonServiceClient(this._address.ToString()) { StoreCookies = true, ShareCookiesWithBrowser = false };
HTTP/1.1 200 OK
Cache-Control: no-store,must-revalidate,no-cache,max-age=0
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Vary: Accept
Server: Microsoft-HTTPAPI/2.0
Set-Cookie: ss-id=5cwF1pftMI0R2LphJMjr;path=/
Set-Cookie: ss-pid=KnLVQCQtQe9pvBilJBXU;path=/;expires=Sun, 14 May 2034 13:34:03 GMT
Set-Cookie: X-UAId=;path=/;expires=Sun, 14 May 2034 13:34:03 GMT
X-Served-By: XY Server/2014.1.0 (rev 0) RC1 - XYServer
X-Powered-By: ServiceStack/4,020 Win32NT/.NET
Date: Wed, 14 May 2014 13:34:03 GMT
但我提出的下一个要求如下:

GET http://localhost:8082/api/server/info HTTP/1.1
Accept: application/json, */*
Accept-Language: nl-NL
Referer: http://localhost:4637/ClientBin/ServerManagerLite.xap
Accept-Encoding: identity
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; InfoPath.3; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; rv:11.0) like Gecko
Host: localhost:8082
DNT: 1
Connection: Keep-Alive
我是否缺少一行重要的代码

更新:这在版本4.0.21中已修复

谢谢,
Robert van Drunen

更新:这在版本4.0.21中已修复

您是否创建了
JsonServiceClient
的新实例以发出第二个请求(即在验证之后)
StoreCookies
允许实例接受Cookie,但不会将它们持久化到新实例。因此,您将丢失身份验证cookie。您需要在应用程序中共享
JsonServiceClient
实例。不,我只使用一个共享的实例。相同的代码用于4.0.9程序集。几周前,我尝试升级到4.0.12程序集,但在ServiceStack内部设置请求用户代理时遇到了NotImplementedException。因为我当时很忙,所以推迟了更新。该异常在4.0.20中消失了,但现在cookies没有被持久化(至少Silverlight没有)