How do I access and ASP page via VB.net

W

Whitecrest

I have a stand alone VB.net application that (after pressing a button) I
would like the VB.net application to call an ASP page, passing
information to it in the query string.

www.somesite.com/registration.asp?id=1234

The ASP will enter the information in a database and return a "key" to
the VB.net application, which will write this "key" to the registry.

What I need to know is how can I make the vb.net application contact the
ASP page, and understand the results.

Thanks
 
C

Cor Ligthert

Hi

Yesterday Nick Holmes, did supply this in the dotnet.general group in C#
code.
I am not sure if it is what you are looking for.

I translated it in VB.net
\\\
Dim myReg As Net.HttpWebRequest = _
DirectCast(Net.WebRequest.Create("www.somesite.com/registration.asp?id=1234"
), _
Net.HttpWebRequest)
Dim myResp As Net.HttpWebResponse = _
DirectCast(myReg.GetResponse(), Net.HttpWebResponse)
Dim myStream As IO.Stream = myResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Dim myPage As String = myreader.ReadToEnd()
myResp.Close()
///


You can try it, when all goes well than you have information from the page
in myPage.
The best would be mshtml, however for this I would just go for getting the
first point with an index of and then the last point from the string
searching the rigth tags and cut your string from it.

There are as well people who use regex solutions for this cutting.

I hope this helps?

When not reply, I think that we than we can use another solution.

Cor
 
H

Herfried K. Wagner [MVP]

* Whitecrest said:
I have a stand alone VB.net application that (after pressing a button) I
would like the VB.net application to call an ASP page, passing
information to it in the query string.

www.somesite.com/registration.asp?id=1234

The ASP will enter the information in a database and return a "key" to
the VB.net application, which will write this "key" to the registry.

What I need to know is how can I make the vb.net application contact the
ASP page, and understand the results.

\\\
Imports System.IO
Imports System.Net
..
..
..
Public Function LoadTextFile(ByVal Url As String) As String
Dim wrq As WebRequest = WebRequest.Create(Url)
Dim wrp As HttpWebResponse = _
DirectCast(wrq.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = _
New StreamReader(wrp.GetResponseStream)
Dim Text As String = sr.ReadToEnd()
sr.Close()
wrp.Close()
Return Text
End Function
..
..
..
Dim s As String = LoadTextFile("http://www.somesite.com/registration.asp?id=1234")
///
 

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

Top