ASP Code migration to ASP.net

G

Guest

I have been facing an issue for past week. Kindly look at the code if some
one can sort it out.

Issue is with the code. I have this ASP code. it connects to a server where
java is running. It send us a response from there. and we need to run that
plain html. As long as the code is in ASP running perfectly fine, But i
convert it to ASP.net it does not show any error. It successfully connects
to server first time, fetch and load the data from the
javaserver. But next time if i click on any link (note these
links are coming from java server). it does not refresh the contents. For
example if i click on the login link. It suppose to bring login form from
server. but it does not, It only refreshes the page. Here is the ASP CODE

<%
Dim lynxUrl, queryString, lynxRequest, lynxServer, binaryData

lynxUrl =
"http://193.128.166.121:8080/uia/director?form_action_url=default.asp&UiaClient=2"
queryString = Request.ServerVariables("QUERY_STRING")

lynxRequest = lynxUrl & queryString
response.Write lynxRequest
response.Write "<br>Sab eik saath ehin <br>"

'sendLynxRequest lynxServer, lynxRequest
response.Write "called SednlYnx request method <br>"
Response.buffer=true
Set lynxServer = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
lynxServer.Option(WinHttpRequestOption_EnableRedirects) = False
response.Write "reqyest mesthogd: " &
Request.ServerVariables("REQUEST_METHOD") &"<br>"
lynxServer.Open Request.ServerVariables("REQUEST_METHOD"), lynxRequest, False

'copyHeadersFromBrowser lynxServer
dim header, splitHeader, headerName, headerValue
response.Write "copyHeadersFromBrowser<br>"
response.Write "raw type : <br> " & Request.ServerVariables("ALL_RAW")
for each header in split(Request.ServerVariables("ALL_RAW"), vbnewline)
if trim(header) <> "" then
splitHeader=split(header, ": ", 2)
headerName=splitHeader(0)
headerValue=splitHeader(1)
lynxServer.setRequestHeader headerName, headerValue
response.Write "h1" & headername &"=" & headerValue & "<br>"
end if
next

binaryData = Request.binaryRead(Request.totalBytes)

lynxServer.send(binaryData)

'receiveLynxResponse lynxServer
Response.Status = lynxServer.status & " " & lynxServer.statusText
Response.BinaryWrite(lynxServer.responseBody)
Response.flush
Response.end
Response = nothing


---------------------------------------------
Here is the ASP.net Code that i converted


<%
Dim queryString, lynxRequest, binaryData As System.Object
Dim lynxServer As System.Object
Dim a
Dim lynxUrl As String
Dim header, doProxy, splitHeader, headerName, lHeaderName,
headerValue As Object


lynxUrl =
"http://193.128.166.121:8080/uia/director?form_action_url=default.aspx&UiaClient=2"
queryString = Request.ServerVariables("QUERY_STRING")

lynxRequest = lynxUrl & queryString
'Response.Buffer = True

lynxServer = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
dim WinHttpRequestOption_EnableRedirects
lynxServer.Option(WinHttpRequestOption_EnableRedirects) = False
a = Request.ServerVariables("REQUEST_METHOD")
lynxServer.Open(a, lynxRequest,false)

For Each header In Split(Request.ServerVariables("ALL_RAW"), vbNewLine)
If Trim(header) <> "" Then
splitHeader = Split(header, ": ", 2)
headerName = splitHeader(0)
headerValue = splitHeader(1)
'lynxServer.setRequestHeader(headerName, headerValue)
' response.Write ("h1" & headername & "=" &
headerValue & "<br>")
End If
Next
binaryData = Request.BinaryRead(Request.TotalBytes)
lynxServer.send(binaryData)
Response.Status = lynxServer.status & " " & lynxServer.statusText
session("res") = lynxServer.ResponseText

response.write (session("res"))
'Response.BinaryWrite(lynxServer.responseBody)
'Response.Flush()
'Response.End()
%>


Kindly if any of you guys can get back to me with a solution. Much
appreciated. Thanks in advance.
 
F

Flinky Wisty Pomm

I think first of all, you should go and read this post
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/msg/31aebf1c39b33b34

You've taken a chunk of procedural vbscript and written the same code
with an object oriented, event driven framework.

Have a look at these links which might get you started:
http://aspnet.4guysfromrolla.com/articles/122204-1.aspx
http://authors.aspalliance.com/stevesmith/articles/netscrape2.asp
http://msdn.microsoft.com/library/d...ml/frlrfSystemNetHttpWebRequestClassTopic.asp

Any specific questions you have, people will be glad to help answer,
but you really can't just write ASP code in VB.Net - it's pointless and
you'll struggle to make or tail of this foolish new-fangled .Net thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top