Xamarin, redirect to page if status code is not Ok
Xamarin, redirect to page if status code is not Ok I have REST API that returns if user exists or not by email. If user exists and I am getting back status OK from API all works fine, but when API response with 404 my app crash. I can't figure out how to check if status is ok or not before app crash and redirect user to register page in case user is not found by API. Here is code that makes request to api: string getuserUrl = $"https://localhost:99282/api/users/{email}"; var client = new HttpClient(); var uri = new Uri(getuserUrl); var result = await client.GetStringAsync(uri); var userResult = JsonConvert.DeserializeObject<User>(result); return userResult; 1 Answer 1 You can use below code to identify whether the API call is success or not. String URL = "https://localhost:99282/api/users/{email}"; using (HttpClien...