以上C#的代码是VB6.0上怎么实现,关于 webrequest,xmlhttp的有关问题
以下C#的代码是VB6.0下如何实现,关于 webrequest,xmlhttp的问题。
这个应该是为了从公司的 svn 下载东西下来,
同事在C#,已经实现了,现在希望在vb6.0上也实现
以下是同事C#实现的关键代码,
'private void Search(string directoryUri, string userName, string password)
' {
' WebRequest request = WebRequest.Create(HttpUtility.UrlPathEncode(directoryUri));
' request.Credentials = new NetworkCredential(userName, password);
' request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;
' request.Proxy = null;
'
' WebResponse response = request.GetResponse();
' Stream stream = response.GetResponseStream();
'
' try
' {
' using (StreamReader reader = new StreamReader(stream))
' {
' string data = reader.ReadToEnd();
' }
' }
' finally
' {
' stream.Close();
' response.Close();
' }
' }
难点在于
1 C#的 WebRequest ,WebResponse 对象,在VB6.0上对应的应该引用什么对象?
2 在这个例子的解决上,我选择了的是 "XMLHTTP"对象,但是出现以下问题
a xmlhttp没有关于 AuthenticationLevel 的相应设置!
b 我用 xmlhttp 的open方法 Sub open(bstrMethod As String, bstrUrl As String, [varAsync], [bstrUser], [bstrPassword]),参数依次为“GET/POST",URL,同步方法,用户,密码
如果填错用户,密码,程序会提示错误,如果填对了,返回 403 (即 403错误,是网站访问过程中,常见的错误提示。资源不可用。服务器理解客户的请求,但拒绝处理它。通常由于服务器上文件或目录的权限设置导致,比如IIS或者apache 设置了访问权限不当。),是否因为 AuthenticationLevel 的相关设置有关?
以上是这个问题的实际情况,是我方法错了,还是思路错了,还是引用的对象错了
------解决方案--------------------
恭喜LZ发现新大陆了,呵呵
这个应该是为了从公司的 svn 下载东西下来,
同事在C#,已经实现了,现在希望在vb6.0上也实现
以下是同事C#实现的关键代码,
'private void Search(string directoryUri, string userName, string password)
' {
' WebRequest request = WebRequest.Create(HttpUtility.UrlPathEncode(directoryUri));
' request.Credentials = new NetworkCredential(userName, password);
' request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;
' request.Proxy = null;
'
' WebResponse response = request.GetResponse();
' Stream stream = response.GetResponseStream();
'
' try
' {
' using (StreamReader reader = new StreamReader(stream))
' {
' string data = reader.ReadToEnd();
' }
' }
' finally
' {
' stream.Close();
' response.Close();
' }
' }
难点在于
1 C#的 WebRequest ,WebResponse 对象,在VB6.0上对应的应该引用什么对象?
2 在这个例子的解决上,我选择了的是 "XMLHTTP"对象,但是出现以下问题
a xmlhttp没有关于 AuthenticationLevel 的相应设置!
b 我用 xmlhttp 的open方法 Sub open(bstrMethod As String, bstrUrl As String, [varAsync], [bstrUser], [bstrPassword]),参数依次为“GET/POST",URL,同步方法,用户,密码
如果填错用户,密码,程序会提示错误,如果填对了,返回 403 (即 403错误,是网站访问过程中,常见的错误提示。资源不可用。服务器理解客户的请求,但拒绝处理它。通常由于服务器上文件或目录的权限设置导致,比如IIS或者apache 设置了访问权限不当。),是否因为 AuthenticationLevel 的相关设置有关?
以上是这个问题的实际情况,是我方法错了,还是思路错了,还是引用的对象错了
------解决方案--------------------
恭喜LZ发现新大陆了,呵呵