I have mobile app (Xamarin Forms for Android and iOS). I need to display some pictures from the server in my application. some pictures do not exist on the server. if the picture does not exist, the server redirects to another page. I need to check in the client if this picture exists, the owner cannot change the server logic. I have two options for checking:
I have mobile app (Xamarin Forms for Android and iOS). I need to display some pictures from the server in my application. some pictures do not exist on the server. if the picture does not exist, the server redirects to another page. I need to check in the client if this picture exists, the owner cannot change the server logic. I have two options for checking: [list] [*] Make a request to the server. I use this code:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("url"); request.Method = "HEAD"; bool exists; try { request.GetResponse(); exists = true; } catch(Exception ex) { exists = false; } [/list] but I don't get an exception because the server redirects and returns a different page. [list] [*]Download a file and check if it is an png or html page. this option seems a little complicated to me. [/list] any advice and tips - I'll be grateful.