我有以下代码绕过本地计算机的代理服务器,然后发送WebRequest。WebRequest从另一个IP生成而不是我的系统IP?
System.Net.HttpWebRequest Request;
System.Net.WebResponse Response;
System.Net.CredentialCache MyCredentialCache;
编辑1
//System.Net.WebProxy proxyObject = new WebProxy("http://172.24.1.87:8080",true);
string strRootURI = "http://172.24.18.240/webdav/";
string strUserName = "UsName";
string strPassword = "Pwd";
// string strDomain = "Domain";
string strQuery = "";
byte[] bytes = null;
System.IO.Stream RequestStream = null;
System.IO.Stream ResponseStream = null;
System.Xml.XmlTextReader XmlReader = null;
try
{
// Build the SQL query.
strQuery = "myWebDavVerb";
// Create a new CredentialCache object and fill it with the network
// credentials required to access the server.
MyCredentialCache = new System.Net.CredentialCache();
MyCredentialCache.Add(new System.Uri(strRootURI), "Basic", new System.Net.NetworkCredential(strUserName, strPassword));//, strDomain)
// Create the HttpWebRequest object.
Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(strRootURI);
// Add the network credentials to the request.
Request.Credentials = MyCredentialCache;
// Request.Proxy = proxyObject;
// Specify the method.
Request.Method = "PROPFIND";
}
现在,当我尝试执行我得到403错误。所以我检查了服务器日志,发现HTTP/1.0请求来自IP 172.24.1.87
,而我的IP是172.24.17.220
。
有没有办法避免这种情况?我认为这是403错误的根本原因。
请帮忙。 谢谢,
Subhen
我已删除了代理SETT默认代理的代理从我的代码现在,但现在的请求来自172.24.1.86 – Simsons 2010-06-28 11:56:31
@Subhen:这可能是你的网络的默认代理? – 2010-06-28 12:05:28
是的,我们可以避免这种情况。因为我尝试过使用Netdrive并通过NetMon进行监控,在这种情况下,NetDrive应用程序未使用代理服务器。它直接从我的IP生成请求。 – Simsons 2010-06-28 12:08:43