|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Why should I get "Run-time error 6"?
I successfully registered a .dll, called HttpServices.dll which includes functions for connecting to a mail server, with regsrv.
When I try to run the following ASP code: <% 'Option Explicit Response.Buffer = True 'Get the application id from query string Dim iAppId iAppId = Request.QueryString("appid") 'If appid exists then login to that application If Request.QueryString("appid") <> "" Then ' 'Here you shoul get all configuration data for the application from the database ' Dim objHttp Dim sAppURL Dim sServer Dim sPort Dim sLoginUserVar Dim sLoginUser Dim sLoginPwdVar Dim sLoginPwd Dim sLoginPage Dim sLoginMethod Dim bResult 'set the application URL sAppURL = "http://localhost:32000/mail" 'set server name for the http connection sServer = "localhost" 'set the server port sPort = 32000 'set the username for login sLoginUserVar = "username" sLoginUser = "admin" 'set the password for login sLoginPwdVar = "password" sLoginPwd = "admin" 'set the application login page sLoginPage = "/mail/login.html" 'set the method of sending login data sLoginMethod = "POST" 'create a HTTP object to send and receive data from the application Set objHttp = Server.CreateObject("HttpServices.HttpPost") 'check for a connection to server On Error Resume Next bResult = objHttp.CheckConnection (sAppUrl) On Error GoTo 0 If Not bResult Then 'there is no connection to server Response.Write "No connection to server" End If 'configure and open a connection to the server objHttp.ServerName = sServer objHttp.ServerPort = sPort objHttp.OpenConnection If Request.QueryString("page") = "" Then 'login to application Dim sHeader Dim sData 'add a request header sHeader = "Content-Type: application/x-www-form-urlencoded" 'add login data sData = sLoginUserVar & "=" & sLoginUser & "&" & sLoginPwdVar & "=" & sLoginPwd 'create and send the request objHttp.CreateRequest sLoginPage, sLoginMethod objHttp.AddRequestHeader sHeader, Len(sHeader) objHttp.SendRequest sData, Len(sData) Else 'get the desired page objHttp.CreateRequest "/mail/" & Request.QueryString("page"), "GET" objHttp.SendRequest End If Else End If 'Response.End strResponseHeaders = Split(objHttp.GetInfo(22), Chr(13) & Chr(10)) For i = 0 To UBound(strResponseHeaders) 'Response.Write strResponseHeaders(i) & "<br>" If InStr(strResponseHeaders(i), ":") > 0 Then strHeader = Split(strResponseHeaders(i), ":") 'Response.Write "->" & strHeader(0) & ":" & Trim(strHeader(1)) & "<br>" Response.AddHeader Trim(strHeader(0)), Trim(strHeader(1)) End If Next Response.Flush strHtml = "" Do strResponse = objHttp.GetChunk strHtml = strHtml & strResponse Loop While strResponse <> "" strNewHtml = "" Set objParser = Server.CreateObject("HttpServices.HtmlParser") objParser.HtmlToParse = strHtml objParser.Parse Dim Tag Dim Attrib Dim lngLastPos lngLastPos = 1 For Each Tag In objParser.HtmlTag For Each Attrib In Tag.Attributes If (UCase(Tag.TagName) = "LINK" And UCase(Attrib.TagAttribute) = "HREF") Or _ (UCase(Tag.TagName) = "IMG" And UCase(Attrib.TagAttribute) = "SRC") Or _ (UCase(Tag.TagName) = "SCRIPT" And UCase(Attrib.TagAttribute) = "SRC") Then If lngLastPos > 0 Then strNewHtml = strNewHtml & Mid(strHtml, lngLastPos, Attrib.Position - lngLastPos) End If strNewHtml = strNewHtml & "http://localhost:32000/mail/" lngLastPos = Attrib.Position End If If UCase(Tag.TagName) = "A" And UCase(Attrib.TagAttribute) = "HREF" Then If lngLastPos > 0 Then strNewHtml = strNewHtml & Mid(strHtml, lngLastPos, Attrib.Position - lngLastPos) End If strQuery = "page=" & Server.URLEncode(Attrib.AttributeValue) strNewHtml = strNewHtml & "loader.asp?" & strQuery lngLastPos = Attrib.Position lngLastPos = lngLastPos + Len(Attrib.AttributeValue) End If Next Next If lngLastPos > 0 Then strNewHtml = strNewHtml & Mid(strHtml, lngLastPos) End If Response.Write strNewHtml Set objHttp = Nothing %> I get the "Run-time error '6'", which err.description I can not find. It also says "check WinInet reference". Any ideas? Thanks. Otilia |
|
#2
|
|||
|
|||
|
I forgot to say that the error is on line : strResponseHeaders = Split(objHttp.GetInfo(22), Chr(13) & Chr(10)).
Otilia |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Why should I get "Run-time error 6"? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|