When my Xamarin.Forms app starts, I need to determine if the bearer-token stored locally is still valid.
Therefore I need to send a webrequest (I'm using the HttpClient in a RestService).
Step one of the application is to check if the bearer token stored in memory is still valid.
Therefore I need to send a webrequest before doing anything else.
Step two is to set the MainPage to either the HomePage or the LoginPage (depending on wether the token is still valid).
The problem is that I'm getting a NullReferenceException when sending a webrequest before setting the MainPage.
I've stripped the code down to the bare minimum. The code is hosted at: https://github.com/PieterjanDeClippel/Xamarin.Forms-HttpClient-Issue
What is the reason I'm getting a NullReferenceException? What does it mean? Why isn't such a simple piece of code working as expected?