iOS的AFNetworking - 的ASP.NET Web API .ASPXAUTH存储和删除 [英] iOS AFNetworking - ASP.NET Web API .ASPXAUTH storage and deletion

查看:524
本文介绍了iOS的AFNetworking - 的ASP.NET Web API .ASPXAUTH存储和删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是AFNetworking框架的iOS。我子类AFHttpClient并使用它作为一个单独的,即 [TestAFClient sharedClient]

I'm using the AFNetworking Framework for iOS. I've subclassed AFHttpClient and are using it as a singleton, i.e. [TestAFClient sharedClient]

我消费,需要使用.ASPXAUTH的cookie的ASP.NET Web服务API。首先,我要认证,获得.ASPXAUTH饼干响应,然后必须通过这个cookie与每个后续请求。

I'm consuming an ASP.NET Web Service API that requires the use of the .ASPXAUTH cookie. First I have to authenticate, receive the .ASPXAUTH cookie in response, and then must pass this cookie with each subsequent request.

一些测试后,它出现,因为我使用的是单AFHTTPClient的.ASPXAUTH饼干仍然存在,因此,需要的cookie没有明确的存储空间。

After a few tests, it appears that, because I'm using a singleton AFHTTPClient, the .ASPXAuth cookie persists and, thus, no explicit storage of the cookie is required.

不过,正如我的应用程序的一部分,我需要注销在某些时候。

However, as part of my App, I need to "logout" at some point.

什么是清除这个cookie,为了注销的最有效方法是什么?设置为零单身到并重新初始化呢?做这样的事情的setValue:forKey:

What is the most efficient way to clear this cookie, in order to logout? Set the singleton to nil and re-initialize it? Do something like setValue:forKey:?

此外,岂不是更好,我明确地存储.ASPXAUTH饼干吗?而这是否到期,或者需要自动更新?

Additionally, is it better that I explicitly store the .ASPXAUTH cookie? And does this expire or automatically renew if necessary?

谢谢,

罗比

推荐答案

Cookie是由底层的URL装载系统实际处理,类似的方式cacheing会自动 NSURLCache 。对于 [NSHTTPCookieStorage sharedHTTPCookieStorage] ,你要找到你的 BASEURL ,然后将其删除该cookie。可以明确地设置或以同样的方式修改现有的cookie。

Cookies are actually handled by the underlying URL-loading system, similar to the way cacheing is handled automatically by NSURLCache. For [NSHTTPCookieStorage sharedHTTPCookieStorage], you'll want to find the cookie at your baseURL, and then delete it. You can explicitly set or modify an existing cookie in the same way.

这篇关于iOS的AFNetworking - 的ASP.NET Web API .ASPXAUTH存储和删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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