Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var credentialStringValue = "proxyUser:proxyPassword";
- byte[] credentialByteArray = ASCIIEncoding.ASCII.GetBytes(credentialStringValue);
- var credentialBase64String = Convert.ToBase64String(credentialByteArray);
- string Headers = string.Format("Proxy-Authorization: Basic {0}{1}", credentialBase64String, Environment.NewLine);
- ws.Navigate(url,TargetFrameName,PostData,Headers);
- // do what you want with proxy class
- WebProxy webProxy = new WebProxy(host, port)
- {
- Credentials = ...
- }
- HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://example.com");
- webRequest.Proxy = webProxy;
- HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
- Stream receiveStream = response.GetResponseStream();
- WebBrowser webBrowser = new WebBrowser();
- webBrowser.DocumentStream = receiveStream;
- Registry.SetValue(keyName, "ProxyServer", proxyhost, RegistryValueKind.String);
- Registry.SetValue(keyName, "ProxyEnable", proxyEnabled ? "1" : "0", RegistryValueKind.DWord);
- Registry.SetValue(keyName, "ProxyPass", password, RegistryValueKind.String);
- Registry.SetValue(keyName, "ProxyUser", username, RegistryValueKind.String);
- //<-loopback>;<local>
- Registry.SetValue(keyName, "ProxyOverride", "*.local", RegistryValueKind.String);
- // These lines implement the Interface in the beginning of program
- // They cause the OS to refresh the settings, causing IP to realy update
- InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
- InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
- }
- Credential credentials= new Credential
- {
- Username = $"Usernmae",
- Password = "Password",
- Target = "Target (usualy proxy domain}",
- Type = CredentialType.Generic,
- PersistanceType = PersistanceType.Enterprise
- };
- credentials.Save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement