Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. public ActionResult Doctor_Schedule(string ids) {
  2. /* Url to another IP */
  3. string LinkUrl = "http://192.168.1.232:6128/MTWS/Mobility/GetDoctorSchedule?resourcemstr=" + ids;
  4. string username = "myuser";
  5. string password = "123456789";
  6. string usernamePassword = username + ":" + password;
  7. HttpWebRequest myWebRequest (HttpWebRequest)WebRequest.Create(LinkUrl);
  8.  
  9. myWebRequest.Method = "POST";
  10. myWebRequest.KeepAlive = true;
  11.  
  12. CredentialCache myCredentials = new CredentialCache();
  13. myCredentials.Add(new Uri(LinkUrl), "Basic aWNoYToxMjM0NQ==", new NetworkCredential(username, password));
  14. myWebRequest.Credentials = myCredentials;
  15.  
  16. myWebRequest.Headers.Add("Authorization", "Basic aWNoYToxMjM0NQ==" + Convert.ToBase64String(new ASCIIEncoding().GetBytes(usernamePassword)));
  17.  
  18. HttpWebResponse wr = (HttpWebResponse)myWebRequest.GetResponse();
  19.  
  20. using (var reponseStream = wr.GetResponseStream())
  21. {
  22. using (var responseReader = new StreamReader(reponseStream, Encoding.UTF8))
  23. {
  24. string contentdata = responseReader.ReadToEnd();
  25. Response.Write(contentdata);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement