Forum Xamarin Xamarin.iOS

issue : NSUrlSession call DidReceiveData method for a sevral times on large response

faafaa USMember ✭✭
edited January 2017 in Xamarin.iOS

Hi I want to get json data from web service using NSUrlSessionDataTask.
My problem that on large response NSUrlSession doesn't return data once but it return data as a parts and pass each part to DidReceiveData method so i get a json Exception while parsing each passing data.
how can i set NSUrlSession pass all data once to DidReceiveData method ?

// HTTP request using NSURLSessionDataTask.
NSUrlSession sess = NSUrlSession.FromConfiguration(NSUrlSessionConfiguration.DefaultSessionConfiguration, new SessionDelegate(this), NSOperationQueue.MainQueue);
// Create and start task
var dataTask = sess.CreateDataTask(new NSUrl("my_url"));

public override void DidReceiveData(NSUrlSession session, NSUrlSessionDataTask dataTask, NSData data)
MsgList = JsonConvert.DeserializeObject<List>(data.ToString());
catch (Exception ex)
var m = ex.Message;

Sign In or Register to comment.