2

I am trying to work with a .NET server that is returning a ASPXAUTH cookie when logging in. I am definitely getting the cookie back when I watch my network traffic with Charles, but when I inspect [NSHTTPCookieStorage sharedHTTPCookieStorage] I am not finding it contains anything. Listed is my code below. Any help would greatly be appreciated!

AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc]
                                          initWithBaseURL:[NSURL URLWithString:@"http://someurl.com/api/"]];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];

NSDictionary *parameters = @{@"UserName":@"SomeUserName", @"Password":@"SomePassword"};

[manager POST:@"User/Login" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {

}  failure:^(AFHTTPRequestOperation *operation, NSError *error) {

}];
67cherries
  • 6,931
  • 7
  • 35
  • 51
TomWildcat
  • 349
  • 3
  • 12

1 Answers1

0

I found the solution as... taking the cookie and setting the http header value like so...

[manager.requestSerializer setValue:[NSString stringWithFormat:@".ASPXAUTH=%@", cookie[@"Value"]] forHTTPHeaderField:@"Cookie"];

.NET expects the cookie returned in the above format. Hope this helps anyone.

TomWildcat
  • 349
  • 3
  • 12