windows phone deserialization json
- by user2042227
I have a weird issue. so I am making a few calls in my app to a webservice, which replies with data. However I am using a token based login system, so the first time the user enters the app I get a token from the webservice to login for that specific user and that token returns only that users details.
The problem I am having is when the user changes I need to make the calls again, to get the new user's details, but using visual studio's breakpoint debugging, it shows the new user's token making the call however the problem is when the json is getting deserialized, it is as if it still reads the old data and deserializes that, when I exit my app with the new user it works fine, so its as if it is reading cached values, but I have no idea how to clear it? I am sure the new calls are being made and the problem lies with the deserializing, but I have tried clearing the values before deserializing them again, however nothing works. am I missing something with the json deserializer, how van I clear its cached values?
here I make the call and set it not to cache so it makes a new call everytime:
client.Headers[HttpRequestHeader.CacheControl] = "no-cache";
var token_details = await client.DownloadStringTaskAsync(uri);
and here I deserialize the result, it is at this section the old data gets shown, so the raw json being shown inside "token_details" is correct, only once I deserialize the token_details, it shows the wrong data.
deserialized = JsonConvert.DeserializeObject(token_details);
and the class I am deserializing into is a simple class nothing special happening here, I have even tried making the constructor so that it clears the values each time it gets called.
public class test
{
public string status { get; set; }
public string name{ get; set; }
public string birthday{ get; set; }
public string errorDes{ get; set; }
public test()
{
status = "";
name= "";
birthday= "";
errorDes= "";
}
}
uri's before making the calls:
{https://whatever.co.za/token/?code=BEBCg==&id=WP7&junk=121edcd5-ad4d-4185-bef0-22a4d27f2d0c} - old call
"UBCg==" - old reply
{https://whatever.co.za/token/?code=ABCg==&id=WP7&junk=56cc2285-a5b8-401e-be21-fec8259de6dd} - new call
"UBCg==" - new response which is the same response as old call
as you can see i did attach a new GUID everytime i make the call, but then the new uri is read before making the downloadstringtaskasync method call, but it returns with the old data