Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://url");
- String username = "abc";
- String password = "123";
- String encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
- httpWebRequest.Headers.Add("Authorization", "Basic " + encoded);
- httpWebRequest.ContentType = "application/json";
- httpWebRequest.Method = "POST";
- public static void AddAuthorizationHeader(ref HttpWebRequest request)
- {
- string username = //load value from web.config
- string password = //load value from web.config
- string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
- request.Headers.Add("Authorization", "Basic " + encoded);
- }
- HttpWebRequest request = new HttpWebRequest();
- UtilityClass.AddAuthorizationHeader(ref request);
- request.ContentType = "application/json";
- request.Method = "POST";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement