1

hi i'm using "instasharper" and when i login to instagram with "instasharper api" i need to save the HttpClientHandler that is use by "instasharper api" for future use and i'm doing this

  string str = JsonConvert.SerializeObject(_HttpClientHandler);

and when i DeserializeObject it i got an error:

  HttpClientHandler hch = JsonConvert.DeserializeObject<HttpClientHandler>(str);

error : System.PlatformNotSupportedException: Operation is not supported on this platform.

Community
  • 1
  • 1
  • Why are you serializing it? – nurdyguy May 15 '17 at 20:38
  • i need to save it in database – Shopping Center CNC May 15 '17 at 20:47
  • I don't know what an `HttpClientHandler` is, but it sure doesn't sound like anything that can or should be serialized. – Sam Axe May 15 '17 at 21:10
  • @ShoppingCenterCNC I just ran a unit test where I created a `HttpClientHandler`, serialized it just like in your example and then deserialized it again just like in your example. No exception was thrown and the resulting object was as it should be. I was unable to reproduce the error you encountered. – Nkosi May 15 '17 at 21:13
  • @ShoppingCenterCNC Even if you can serialize it, save it to db, retrieve it, and deserialize back to an object, the resulting object will be a new object. It may have some of the same property values as the original but that is the only similarity. In general httpClients are intended to be short lived, typically within a using statement. If there are specific properties you need to preserve then I recommend forming your db around that idea. – nurdyguy May 15 '17 at 21:30
  • so what should i do? how can i save httpclienthandeler – Shopping Center CNC May 16 '17 at 08:20
  • @nurdyguy before thinking of this i was saving it it Session is there any other alternative way – Shopping Center CNC May 16 '17 at 11:15
  • @ShoppingCenterCNC The better question is: Why do you think you need to keep reusing the same httpClientHandler? I looked at the instasharp github repo and I don't see anything in the documentation saying you need to do that. – nurdyguy May 16 '17 at 14:36

0 Answers0