1 2 3 4 5 6 |
HttpWebRequest req = (HttpWebRequest)WebRequest<span class="hljs-preprocessor">.Create</span>(url)<span class="hljs-comment">;</span> NetworkCredential d = new NetworkCredential(<span class="hljs-string">"USERNAME"</span>, <span class="hljs-string">"PASSWORD"</span>)<span class="hljs-comment">;//添加此代码</span> req<span class="hljs-preprocessor">.Credentials</span> = d<span class="hljs-comment">;</span> HttpWebResponse resp = (HttpWebResponse)req<span class="hljs-preprocessor">.GetResponse</span>()<span class="hljs-comment">;</span> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<span class="hljs-tag"><<span class="hljs-title">system.net</span>></span> <span class="hljs-comment"><!--使用Web代理的设置--></span> <span class="hljs-comment"><!--usesystemdefault指定是否使用 Internet Explorer 代理设置。 如果设置为 true,则后面的特性将重写 Internet Explorer 代理设置。 默认值为 unspecified。--></span> <span class="hljs-tag"><<span class="hljs-title">defaultProxy</span>></span> <span class="hljs-tag"><<span class="hljs-title">proxy </span> <span class="hljs-attribute">usesystemdefault</span>=<span class="hljs-value">"True"</span> <span class="hljs-attribute">proxyaddress</span>=<span class="hljs-value">"http://172.27.1.191:80"</span> <span class="hljs-attribute">bypassonlocal</span>=<span class="hljs-value">"True"</span> /></span> <span class="hljs-tag"><<span class="hljs-title">bypasslist</span>></span> <span class="hljs-tag"><<span class="hljs-title">add</span> <span class="hljs-attribute">address</span>=<span class="hljs-value">"172\.27\.\d{1,3}\.\d{1,3}"</span> /></span> <span class="hljs-tag"></<span class="hljs-title">bypasslist</span>></span> <span class="hljs-tag"></<span class="hljs-title">defaultProxy</span>></span> <span class="hljs-tag"></<span class="hljs-title">system.net</span>> </span> |
http://blog.csdn.net/mang_liu/article/details/7708864