如何通过代理服务器访问Internet在C# [英] How to access the Internet through Proxy in C#

查看:192
本文介绍了如何通过代理服务器访问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

这篇关于如何通过代理服务器访问Internet在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆