1

我正在尝试创建一个连接到外部网站、登录然后传递一堆参数的简单页面。

当我运行该页面时,我收到一个错误的请求 400 错误,当我使用 Fiddler 检查时,我可以看到同时返回了 401 和 400 错误。在提琴手的“身份验证”下,我看到:

“不存在代理授权标头。不存在授权标头。” < 这有关系吗?当我使用 PHP cUrl 进行测试时,页面可以正常登录,而 Fiddler 在 Auth 下也是如此。

    Dim UserName As String = "testusername"
    Dim password As String = "testpassword"
    Dim siteCredentials As New NetworkCredential(UserName, password)

    Dim URLAuth As String = "http://service.someurl.com/process.xml"
    Dim postString As String = String.Format("customeremailaddress={0}&customername={1}&referenceid={2}&languagecode={3}&expirydays={4}", customeremailaddress, customername, referenceid, languagecode, expirydays)

    Dim postBytes As Byte() = Encoding.UTF8.GetBytes(postString)

    Const contentType As String = "application/x-www-form-urlencoded"
    System.Net.ServicePointManager.Expect100Continue = False

    Dim cookies As New CookieContainer()
    Dim webRequest__1 As HttpWebRequest = TryCast(WebRequest.Create(URLAuth), HttpWebRequest)
    webRequest__1.Method = "POST"
    webRequest__1.ContentType = contentType
    webRequest__1.CookieContainer = cookies
    webRequest__1.ContentLength = postBytes.Length
    webRequest__1.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"
    webRequest__1.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
    webRequest__1.Referer = "http://service.someurl.com/process.xml"
    webRequest__1.Credentials = siteCredentials

    Try
        Dim requestStream As Stream = webRequest__1.GetRequestStream()
        requestStream.Write(postBytes, 0, postBytes.Length)
        Dim testcapture As String = requestStream.ToString
        Dim thing As String = "stop"

        Dim responseReader As New StreamReader(webRequest__1.GetResponse().GetResponseStream())
        Dim responseData As String = responseReader.ReadToEnd()
        responseReader.Close()
        webRequest__1.GetResponse().Close()

    Catch ex As Exception
        Lbl_ConnTest_error.Text = ex.Message
    End Try   

似乎没有通过登录凭据我做错了什么?我显然在 asp.net 应用程序中使用 vb,但正在连接到 Linux Apache 上保存的 XML 文件,这有什么影响吗?

Fiddler 现在似乎在为我做一些奇怪的事情,所以如果其他人可以使用 Fiddler 看到任何东西,那么这里有一个指向测试文件的链接: http ://www.filemanage.co.uk/Pubs/Default.aspx

4

0 回答 0