Hi
i have some Login API Url "Url";
After hitting url on web browser its gave me response as valid /Invalid
can anyone tell me how to use login api in c# windows Application
Thanks
Check with the below code.
public string GetResponse(string url) { string sContents = string.Empty; string me = string.Empty; try { if (url.ToLower().IndexOf("http:") > -1) { System.Net.WebClient client = new System.Net.WebClient(); byte[] response = client.DownloadData(url); sContents = System.Text.Encoding.ASCII.GetString(response); } else { System.IO.StreamReader sr = new System.IO.StreamReader(url); sContents = sr.ReadToEnd(); sr.Close(); } } catch { sContents = "unable to connect to server "; } return sContents; }
© COPYRIGHT 2024 ASPSnippets.com ALL RIGHTS RESERVED.