如何通过代理服务器访问Internet在C#

问题描述:

设计一个Windows窗体应用程序使用C#,我面临的一个问题。当连接到互联网,但是当我们试图在我们的大学申请,真正的问题开始申请执行其职能顺利。

Designing a Windows Forms application using C#, i am facing a problem. The application performs its functions smoothly when connected to the Internet but the real problem starts when we try the application in our College.

我们的学院将连接到使用代理网关网。代理服务器为192.168.120.5和代理端口8080。每到学生被赋予一个唯一的用户名和密码。

Our College connects to the Net using proxy gateways. The Proxy server is "192.168.120.5" and Proxy Port "8080".Every Student is given an unique user name and password.

我怎样才能获得成功,通过这个障碍?将使用

How can i get ahead through this obstacle ?? Will using

WebRequest request = WebRequest.Create("http://www.mysite.com");  
request.Proxy = new WebProxy("192.168.120.5", 8080); 

帮助我以任何方式? 。如果是的话,我在哪里输入用户名和密码凭证

help me in any way ?? . If yes, where do I enter the Username and Password Credentials

感谢您帮助了

是的,你可以使用...虽然它可能是简单的使用WebRequest.DefaultWebProxy

yes you can use that... though it may be simpler use the WebRequest.DefaultWebProxy

WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
proxyObject.Credientials = new NetworkCredential(UserName, "bla");
WebRequest req = WebRequest.Create("http://www.contoso.com");
req.Proxy = proxyObject;

但作为一个方面说明,你可以通过设置
使用本地默认凭据

though as a side note you may be able to use the local default credentials by setting

proxyObject.UseDefaultCredentials = true;

如果您尝试使用,你必须确保proxyObject.Credintials = NULL。
MSDN网站上的这一切都是在这里 MSDN WebProxy

If you do try to use that you have to make sure that proxyObject.Credintials = null.
The msdn site on all of this is here MSDN WebProxy