473,889 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting results from the server

Hello,

I have a simple client-side form that is checking the domain availability on
the domain registrar's server:

<FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl" method="post">
<input type="hidden" name="thisPage" value="pispChec kDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_na me"><br>
<input type="submit" runat="server" id="Submit1" value="Submit Query"
name="Submit1">
</FORM>

It sends parameter thisPage with the value pispCheckDomain that tells the
system to check availability of a domain domain_name.

The server responds like this: Success: <domain name> is Available or
Success: <domain name> is Unavailable. I can see it on the page
https://www.webnames.ru/scripts/RegTimeSRS.pl

How can I get these results to my page using ASP.NET? There is no
information that the server returns any parameters, so I need to construct
the request myself. I usually use Request.QuerySt ring("param") or
request.Form("p aram"), but in this case there is no "param" specified.
Should be pretty easy task for a web programmer, but I've never done this
before. This should be similar to querying Whois results.

I would appreciate your advice.

Thank you,

--
Peter Afonin
Nov 19 '05 #1
10 1949
Hi Peter,
Have a look at the System.Net.Http WebRequest object and use it to create a
form post, you can then read the response and take any action you require

HTH jd

"Peter Afonin" wrote:
Hello,

I have a simple client-side form that is checking the domain availability on
the domain registrar's server:

<FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl" method="post">
<input type="hidden" name="thisPage" value="pispChec kDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_na me"><br>
<input type="submit" runat="server" id="Submit1" value="Submit Query"
name="Submit1">
</FORM>

It sends parameter thisPage with the value pispCheckDomain that tells the
system to check availability of a domain domain_name.

The server responds like this: Success: <domain name> is Available or
Success: <domain name> is Unavailable. I can see it on the page
https://www.webnames.ru/scripts/RegTimeSRS.pl

How can I get these results to my page using ASP.NET? There is no
information that the server returns any parameters, so I need to construct
the request myself. I usually use Request.QuerySt ring("param") or
request.Form("p aram"), but in this case there is no "param" specified.
Should be pretty easy task for a web programmer, but I've never done this
before. This should be similar to querying Whois results.

I would appreciate your advice.

Thank you,

--
Peter Afonin

Nov 19 '05 #2
Hi,

Thank you.

No, but I'll look at it. I've set up several systems like this, and always I
was submitting my URL as a parameter so the system would send me the
response to this address. In this case, however, it's not required, and this
is what I cannot understand.

The developer said that they are using module LWP in Perl, but he doesn't
know what to use in ASP or ASP.NET.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
Hi Peter,
Have a look at the System.Net.Http WebRequest object and use it to create a
form post, you can then read the response and take any action you require

HTH jd

"Peter Afonin" wrote:
Hello,

I have a simple client-side form that is checking the domain availability
on
the domain registrar's server:

<FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
method="post">
<input type="hidden" name="thisPage" value="pispChec kDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_na me"><br>
<input type="submit" runat="server" id="Submit1" value="Submit Query"
name="Submit1">
</FORM>

It sends parameter thisPage with the value pispCheckDomain that tells the
system to check availability of a domain domain_name.

The server responds like this: Success: <domain name> is Available or
Success: <domain name> is Unavailable. I can see it on the page
https://www.webnames.ru/scripts/RegTimeSRS.pl

How can I get these results to my page using ASP.NET? There is no
information that the server returns any parameters, so I need to
construct
the request myself. I usually use Request.QuerySt ring("param") or
request.Form("p aram"), but in this case there is no "param" specified.
Should be pretty easy task for a web programmer, but I've never done this
before. This should be similar to querying Whois results.

I would appreciate your advice.

Thank you,

--
Peter Afonin

Nov 19 '05 #3
Hi Peter,

If I understand correctly the result you are looking for is the 'page'
output, though probably in plain text (the link you posted gives me an
error).

If you use the HttpWebRequest to post your form information (e.g the domain
you're looking for etc) to the server you get an HttpWebResponse object back.

This (httpWebRespons e) object
contains among otherthings, a method called GetResponseStre am which is a
System.IO.Strea m containing the page output.

Read this stream using a Syatem.IO.Strea mReader object to get the page body
- in this case the string "success: suchadomain.com is availiable".

You then need to parse the string probably by splitting it on space chars
and analysing the parts of the string array

HTH jd

"Peter Afonin" wrote:
Hi,

Thank you.

No, but I'll look at it. I've set up several systems like this, and always I
was submitting my URL as a parameter so the system would send me the
response to this address. In this case, however, it's not required, and this
is what I cannot understand.

The developer said that they are using module LWP in Perl, but he doesn't
know what to use in ASP or ASP.NET.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
Hi Peter,
Have a look at the System.Net.Http WebRequest object and use it to create a
form post, you can then read the response and take any action you require

HTH jd

"Peter Afonin" wrote:
Hello,

I have a simple client-side form that is checking the domain availability
on
the domain registrar's server:

<FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
method="post">
<input type="hidden" name="thisPage" value="pispChec kDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_na me"><br>
<input type="submit" runat="server" id="Submit1" value="Submit Query"
name="Submit1">
</FORM>

It sends parameter thisPage with the value pispCheckDomain that tells the
system to check availability of a domain domain_name.

The server responds like this: Success: <domain name> is Available or
Success: <domain name> is Unavailable. I can see it on the page
https://www.webnames.ru/scripts/RegTimeSRS.pl

How can I get these results to my page using ASP.NET? There is no
information that the server returns any parameters, so I need to
construct
the request myself. I usually use Request.QuerySt ring("param") or
request.Form("p aram"), but in this case there is no "param" specified.
Should be pretty easy task for a web programmer, but I've never done this
before. This should be similar to querying Whois results.

I would appreciate your advice.

Thank you,

--
Peter Afonin


Nov 19 '05 #4
Hi,

Thank you, I've read about this object, I guess this is exactly what I need.

I haven't tried it yet, but I will today. One thing I'm not sure about yet.

It works this way. You submit the form to
https://www.webnames.ru/scripts/RegTimeSRS.pl, it returns a page saying
something like this: Success. Domain <domain_name> is unavaliable. I have to
read this page.

This object httpWebResponse does exactly this. But the system returns the
response on the same dynamic page,
https://www.webnames.ru/scripts/RegTimeSRS.pl, so I'm not sure how it will
read it. I guess I have to try.

Thanks again,

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:F1******** *************** ***********@mic rosoft.com...
Hi Peter,

If I understand correctly the result you are looking for is the 'page'
output, though probably in plain text (the link you posted gives me an
error).

If you use the HttpWebRequest to post your form information (e.g the
domain
you're looking for etc) to the server you get an HttpWebResponse object
back.

This (httpWebRespons e) object
contains among otherthings, a method called GetResponseStre am which is a
System.IO.Strea m containing the page output.

Read this stream using a Syatem.IO.Strea mReader object to get the page
body
- in this case the string "success: suchadomain.com is availiable".

You then need to parse the string probably by splitting it on space chars
and analysing the parts of the string array

HTH jd

"Peter Afonin" wrote:
Hi,

Thank you.

No, but I'll look at it. I've set up several systems like this, and
always I
was submitting my URL as a parameter so the system would send me the
response to this address. In this case, however, it's not required, and
this
is what I cannot understand.

The developer said that they are using module LWP in Perl, but he doesn't
know what to use in ASP or ASP.NET.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in
message
news:E3******** *************** ***********@mic rosoft.com...
> Hi Peter,
> Have a look at the System.Net.Http WebRequest object and use it to
> create a
> form post, you can then read the response and take any action you
> require
>
> HTH jd
>
> "Peter Afonin" wrote:
>
>> Hello,
>>
>> I have a simple client-side form that is checking the domain
>> availability
>> on
>> the domain registrar's server:
>>
>> <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
>> method="post">
>> <input type="hidden" name="thisPage" value="pispChec kDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_na me"><br>
>> <input type="submit" runat="server" id="Submit1" value="Submit
>> Query"
>> name="Submit1">
>> </FORM>
>>
>> It sends parameter thisPage with the value pispCheckDomain that tells
>> the
>> system to check availability of a domain domain_name.
>>
>> The server responds like this: Success: <domain name> is Available or
>> Success: <domain name> is Unavailable. I can see it on the page
>> https://www.webnames.ru/scripts/RegTimeSRS.pl
>>
>> How can I get these results to my page using ASP.NET? There is no
>> information that the server returns any parameters, so I need to
>> construct
>> the request myself. I usually use Request.QuerySt ring("param") or
>> request.Form("p aram"), but in this case there is no "param" specified.
>> Should be pretty easy task for a web programmer, but I've never done
>> this
>> before. This should be similar to querying Whois results.
>>
>> I would appreciate your advice.
>>
>> Thank you,
>>
>> --
>> Peter Afonin
>>
>>
>>


Nov 19 '05 #5
Hi,

I've found all code, but there is one thing I'm struggling with now:

When I post my form results, I'm getting redirected to the page
https://www.webnames.ru/scripts/RegTimeSRS.pl. How do I get back to my page
to read the results?

Thank you,

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:F1******** *************** ***********@mic rosoft.com...
Hi Peter,

If I understand correctly the result you are looking for is the 'page'
output, though probably in plain text (the link you posted gives me an
error).

If you use the HttpWebRequest to post your form information (e.g the
domain
you're looking for etc) to the server you get an HttpWebResponse object
back.

This (httpWebRespons e) object
contains among otherthings, a method called GetResponseStre am which is a
System.IO.Strea m containing the page output.

Read this stream using a Syatem.IO.Strea mReader object to get the page
body
- in this case the string "success: suchadomain.com is availiable".

You then need to parse the string probably by splitting it on space chars
and analysing the parts of the string array

HTH jd

"Peter Afonin" wrote:
Hi,

Thank you.

No, but I'll look at it. I've set up several systems like this, and
always I
was submitting my URL as a parameter so the system would send me the
response to this address. In this case, however, it's not required, and
this
is what I cannot understand.

The developer said that they are using module LWP in Perl, but he doesn't
know what to use in ASP or ASP.NET.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in
message
news:E3******** *************** ***********@mic rosoft.com...
> Hi Peter,
> Have a look at the System.Net.Http WebRequest object and use it to
> create a
> form post, you can then read the response and take any action you
> require
>
> HTH jd
>
> "Peter Afonin" wrote:
>
>> Hello,
>>
>> I have a simple client-side form that is checking the domain
>> availability
>> on
>> the domain registrar's server:
>>
>> <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
>> method="post">
>> <input type="hidden" name="thisPage" value="pispChec kDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_na me"><br>
>> <input type="submit" runat="server" id="Submit1" value="Submit
>> Query"
>> name="Submit1">
>> </FORM>
>>
>> It sends parameter thisPage with the value pispCheckDomain that tells
>> the
>> system to check availability of a domain domain_name.
>>
>> The server responds like this: Success: <domain name> is Available or
>> Success: <domain name> is Unavailable. I can see it on the page
>> https://www.webnames.ru/scripts/RegTimeSRS.pl
>>
>> How can I get these results to my page using ASP.NET? There is no
>> information that the server returns any parameters, so I need to
>> construct
>> the request myself. I usually use Request.QuerySt ring("param") or
>> request.Form("p aram"), but in this case there is no "param" specified.
>> Should be pretty easy task for a web programmer, but I've never done
>> this
>> before. This should be similar to querying Whois results.
>>
>> I would appreciate your advice.
>>
>> Thank you,
>>
>> --
>> Peter Afonin
>>
>>
>>


Nov 19 '05 #6
I guess this is a better question: how should I post the form data using
HttpWebRequest object instead of the way I'm doing it now?

I've found the code sample:

Dim result As String = ""
Dim strPost As String = "x=1&y=2&z=YouP ostedOk"
Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Crea te(url)
objRequest.Meth od = "POST"
objRequest.Cont entLength = strPost.Length
objRequest.Cont entType = "applicatio n/x-www-form-urlencoded"

Is this a way I should post it - as a string, where x, y and z are the field
names? Or am I missing something?

Thank you,

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:F1******** *************** ***********@mic rosoft.com...
Hi Peter,

If I understand correctly the result you are looking for is the 'page'
output, though probably in plain text (the link you posted gives me an
error).

If you use the HttpWebRequest to post your form information (e.g the domain you're looking for etc) to the server you get an HttpWebResponse object back.
This (httpWebRespons e) object
contains among otherthings, a method called GetResponseStre am which is a
System.IO.Strea m containing the page output.

Read this stream using a Syatem.IO.Strea mReader object to get the page body - in this case the string "success: suchadomain.com is availiable".

You then need to parse the string probably by splitting it on space chars
and analysing the parts of the string array

HTH jd

"Peter Afonin" wrote:
Hi,

Thank you.

No, but I'll look at it. I've set up several systems like this, and always I was submitting my URL as a parameter so the system would send me the
response to this address. In this case, however, it's not required, and this is what I cannot understand.

The developer said that they are using module LWP in Perl, but he doesn't know what to use in ASP or ASP.NET.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message news:E3******** *************** ***********@mic rosoft.com...
Hi Peter,
Have a look at the System.Net.Http WebRequest object and use it to create a form post, you can then read the response and take any action you require
HTH jd

"Peter Afonin" wrote:

> Hello,
>
> I have a simple client-side form that is checking the domain availability> on
> the domain registrar's server:
>
> <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
> method="post">
> <input type="hidden" name="thisPage" value="pispChec kDomain">
> <input type="hidden" name="username" value="test">
> <input type="hidden" name="password" value="test">
> domain_name: <input type="text" name="domain_na me"><br>
> <input type="submit" runat="server" id="Submit1" value="Submit Query"> name="Submit1">
> </FORM>
>
> It sends parameter thisPage with the value pispCheckDomain that tells the> system to check availability of a domain domain_name.
>
> The server responds like this: Success: <domain name> is Available or
> Success: <domain name> is Unavailable. I can see it on the page
> https://www.webnames.ru/scripts/RegTimeSRS.pl
>
> How can I get these results to my page using ASP.NET? There is no
> information that the server returns any parameters, so I need to
> construct
> the request myself. I usually use Request.QuerySt ring("param") or
> request.Form("p aram"), but in this case there is no "param" specified.> Should be pretty easy task for a web programmer, but I've never done this> before. This should be similar to querying Whois results.
>
> I would appreciate your advice.
>
> Thank you,
>
> --
> Peter Afonin
>
>
>


Nov 19 '05 #7
Hi Again Peter below is a function to post to a url and receive the response
(note the class I copied it from has a property called TimeOutMs which does
what it says really, waits TimeOutMs Milliseconds before aborting). As far as
I can see your form string ("x=1&y=2") seems fine. Often you would use a
NameValue (E.g Request object) Collection to collect your data before
building your string. From memory the string mustn't have a leading ampersand
(&). HTH jd

Private Function DoPostToServer( ByVal formContents As String, ByVal
postUrl As String) As String
Debug.WriteLine ("DoPostToServe r")
Dim sResponseString As String = ""

Dim myFormBytes() As Byte =
Text.ASCIIEncod ing.ASCII.GetBy tes(formContent s)

Dim myRequest As Net.HttpWebRequ est = Net.WebRequest. Create(postUrl)
myRequest.Conte ntType = "applicatio n/x-www-form-urlencoded"
myRequest.Metho d = "POST"
myRequest.Timeo ut = Me.TimeOutMs
myRequest.Conte ntLength = myFormBytes.Len gth

Dim failure As Boolean = False
Dim outputStream As IO.Stream

Try
outputStream = myRequest.GetRe questStream()
outputStream.Wr ite(myFormBytes , 0, myFormBytes.Len gth)
Catch ex As Exception
failure = True
Debug.WriteLine (ex.StackTrace + " " + ex.Message)
Finally
If Not outputStream Is Nothing Then
outputStream.Cl ose()
End If
End Try

Dim myResponse As Net.HttpWebResp onse
Dim myStreamReader As IO.StreamReader
Dim inputStream As IO.Stream

If Not failure Then
Dim responseSring As String
Try
myResponse = myRequest.GetRe sponse
inputStream = myResponse.GetR esponseStream
myStreamReader = New IO.StreamReader (inputStream)

sResponseString = myStreamReader. ReadToEnd

Catch ex As Exception
failure = True
Debug.WriteLine (ex.StackTrace + " " + ex.Message)
Finally
If Not myStreamReader Is Nothing Then

myStreamReader. Close()
End If
If Not inputStream Is Nothing Then
inputStream.Clo se()
End If
If Not myResponse Is Nothing Then
myResponse.Clos e()
End If
End Try
End If
Debug.WriteLine (sResponseStrin g)
Return sResponseString
End Function

"Peter Afonin" wrote:
I guess this is a better question: how should I post the form data using
HttpWebRequest object instead of the way I'm doing it now?

I've found the code sample:

Dim result As String = ""
Dim strPost As String = "x=1&y=2&z=YouP ostedOk"
Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Crea te(url)
objRequest.Meth od = "POST"
objRequest.Cont entLength = strPost.Length
objRequest.Cont entType = "applicatio n/x-www-form-urlencoded"

Is this a way I should post it - as a string, where x, y and z are the field
names? Or am I missing something?

Thank you,

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:F1******** *************** ***********@mic rosoft.com...
Hi Peter,

If I understand correctly the result you are looking for is the 'page'
output, though probably in plain text (the link you posted gives me an
error).

If you use the HttpWebRequest to post your form information (e.g the

domain
you're looking for etc) to the server you get an HttpWebResponse object

back.

This (httpWebRespons e) object
contains among otherthings, a method called GetResponseStre am which is a
System.IO.Strea m containing the page output.

Read this stream using a Syatem.IO.Strea mReader object to get the page

body
- in this case the string "success: suchadomain.com is availiable".

You then need to parse the string probably by splitting it on space chars
and analysing the parts of the string array

HTH jd

"Peter Afonin" wrote:
Hi,

Thank you.

No, but I'll look at it. I've set up several systems like this, and always I was submitting my URL as a parameter so the system would send me the
response to this address. In this case, however, it's not required, and this is what I cannot understand.

The developer said that they are using module LWP in Perl, but he doesn't know what to use in ASP or ASP.NET.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message news:E3******** *************** ***********@mic rosoft.com...
> Hi Peter,
> Have a look at the System.Net.Http WebRequest object and use it to create a > form post, you can then read the response and take any action you require >
> HTH jd
>
> "Peter Afonin" wrote:
>
>> Hello,
>>
>> I have a simple client-side form that is checking the domain availability >> on
>> the domain registrar's server:
>>
>> <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
>> method="post">
>> <input type="hidden" name="thisPage" value="pispChec kDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_na me"><br>
>> <input type="submit" runat="server" id="Submit1" value="Submit Query" >> name="Submit1">
>> </FORM>
>>
>> It sends parameter thisPage with the value pispCheckDomain that tells the >> system to check availability of a domain domain_name.
>>
>> The server responds like this: Success: <domain name> is Available or
>> Success: <domain name> is Unavailable. I can see it on the page
>> https://www.webnames.ru/scripts/RegTimeSRS.pl
>>
>> How can I get these results to my page using ASP.NET? There is no
>> information that the server returns any parameters, so I need to
>> construct
>> the request myself. I usually use Request.QuerySt ring("param") or
>> request.Form("p aram"), but in this case there is no "param" specified. >> Should be pretty easy task for a web programmer, but I've never done this >> before. This should be similar to querying Whois results.
>>
>> I would appreciate your advice.
>>
>> Thank you,
>>
>> --
>> Peter Afonin
>>
>>
>>


Nov 19 '05 #8
You could try

myWebRequestObj ect.AllowAutoRe direct = False

I'm wondering if the script you post to requires authentication (i.e login)
before it will let you post to it?

HTH jd
"Peter Afonin" wrote:
Hi,

I've found all code, but there is one thing I'm struggling with now:

When I post my form results, I'm getting redirected to the page
https://www.webnames.ru/scripts/RegTimeSRS.pl. How do I get back to my page
to read the results?

Thank you,

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:F1******** *************** ***********@mic rosoft.com...
Hi Peter,

If I understand correctly the result you are looking for is the 'page'
output, though probably in plain text (the link you posted gives me an
error).

If you use the HttpWebRequest to post your form information (e.g the
domain
you're looking for etc) to the server you get an HttpWebResponse object
back.

This (httpWebRespons e) object
contains among otherthings, a method called GetResponseStre am which is a
System.IO.Strea m containing the page output.

Read this stream using a Syatem.IO.Strea mReader object to get the page
body
- in this case the string "success: suchadomain.com is availiable".

You then need to parse the string probably by splitting it on space chars
and analysing the parts of the string array

HTH jd

"Peter Afonin" wrote:
Hi,

Thank you.

No, but I'll look at it. I've set up several systems like this, and
always I
was submitting my URL as a parameter so the system would send me the
response to this address. In this case, however, it's not required, and
this
is what I cannot understand.

The developer said that they are using module LWP in Perl, but he doesn't
know what to use in ASP or ASP.NET.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in
message
news:E3******** *************** ***********@mic rosoft.com...
> Hi Peter,
> Have a look at the System.Net.Http WebRequest object and use it to
> create a
> form post, you can then read the response and take any action you
> require
>
> HTH jd
>
> "Peter Afonin" wrote:
>
>> Hello,
>>
>> I have a simple client-side form that is checking the domain
>> availability
>> on
>> the domain registrar's server:
>>
>> <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
>> method="post">
>> <input type="hidden" name="thisPage" value="pispChec kDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_na me"><br>
>> <input type="submit" runat="server" id="Submit1" value="Submit
>> Query"
>> name="Submit1">
>> </FORM>
>>
>> It sends parameter thisPage with the value pispCheckDomain that tells
>> the
>> system to check availability of a domain domain_name.
>>
>> The server responds like this: Success: <domain name> is Available or
>> Success: <domain name> is Unavailable. I can see it on the page
>> https://www.webnames.ru/scripts/RegTimeSRS.pl
>>
>> How can I get these results to my page using ASP.NET? There is no
>> information that the server returns any parameters, so I need to
>> construct
>> the request myself. I usually use Request.QuerySt ring("param") or
>> request.Form("p aram"), but in this case there is no "param" specified.
>> Should be pretty easy task for a web programmer, but I've never done
>> this
>> before. This should be similar to querying Whois results.
>>
>> I would appreciate your advice.
>>
>> Thank you,
>>
>> --
>> Peter Afonin
>>
>>
>>


Nov 19 '05 #9
Thank you very much, I really appreciate your help! I'll try this today.

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
Hi Again Peter below is a function to post to a url and receive the response (note the class I copied it from has a property called TimeOutMs which does what it says really, waits TimeOutMs Milliseconds before aborting). As far as I can see your form string ("x=1&y=2") seems fine. Often you would use a
NameValue (E.g Request object) Collection to collect your data before
building your string. From memory the string mustn't have a leading ampersand (&). HTH jd

Private Function DoPostToServer( ByVal formContents As String, ByVal
postUrl As String) As String
Debug.WriteLine ("DoPostToServe r")
Dim sResponseString As String = ""

Dim myFormBytes() As Byte =
Text.ASCIIEncod ing.ASCII.GetBy tes(formContent s)

Dim myRequest As Net.HttpWebRequ est = Net.WebRequest. Create(postUrl) myRequest.Conte ntType = "applicatio n/x-www-form-urlencoded"
myRequest.Metho d = "POST"
myRequest.Timeo ut = Me.TimeOutMs
myRequest.Conte ntLength = myFormBytes.Len gth

Dim failure As Boolean = False
Dim outputStream As IO.Stream

Try
outputStream = myRequest.GetRe questStream()
outputStream.Wr ite(myFormBytes , 0, myFormBytes.Len gth)
Catch ex As Exception
failure = True
Debug.WriteLine (ex.StackTrace + " " + ex.Message)
Finally
If Not outputStream Is Nothing Then
outputStream.Cl ose()
End If
End Try

Dim myResponse As Net.HttpWebResp onse
Dim myStreamReader As IO.StreamReader
Dim inputStream As IO.Stream

If Not failure Then
Dim responseSring As String
Try
myResponse = myRequest.GetRe sponse
inputStream = myResponse.GetR esponseStream
myStreamReader = New IO.StreamReader (inputStream)

sResponseString = myStreamReader. ReadToEnd

Catch ex As Exception
failure = True
Debug.WriteLine (ex.StackTrace + " " + ex.Message)
Finally
If Not myStreamReader Is Nothing Then

myStreamReader. Close()
End If
If Not inputStream Is Nothing Then
inputStream.Clo se()
End If
If Not myResponse Is Nothing Then
myResponse.Clos e()
End If
End Try
End If
Debug.WriteLine (sResponseStrin g)
Return sResponseString
End Function

"Peter Afonin" wrote:
I guess this is a better question: how should I post the form data using
HttpWebRequest object instead of the way I'm doing it now?

I've found the code sample:

Dim result As String = ""
Dim strPost As String = "x=1&y=2&z=YouP ostedOk"
Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Crea te(url)
objRequest.Meth od = "POST"
objRequest.Cont entLength = strPost.Length
objRequest.Cont entType = "applicatio n/x-www-form-urlencoded"

Is this a way I should post it - as a string, where x, y and z are the field names? Or am I missing something?

Thank you,

Peter

"london calling" <lo***********@ discussions.mic rosoft.com> wrote in message news:F1******** *************** ***********@mic rosoft.com...
Hi Peter,

If I understand correctly the result you are looking for is the 'page'
output, though probably in plain text (the link you posted gives me an error).

If you use the HttpWebRequest to post your form information (e.g the

domain
you're looking for etc) to the server you get an HttpWebResponse object
back.

This (httpWebRespons e) object
contains among otherthings, a method called GetResponseStre am which is
a System.IO.Strea m containing the page output.

Read this stream using a Syatem.IO.Strea mReader object to get the page

body
- in this case the string "success: suchadomain.com is availiable".

You then need to parse the string probably by splitting it on space chars and analysing the parts of the string array

HTH jd

"Peter Afonin" wrote:

> Hi,
>
> Thank you.
>
> No, but I'll look at it. I've set up several systems like this, and

always I
> was submitting my URL as a parameter so the system would send me the
> response to this address. In this case, however, it's not required, and this
> is what I cannot understand.
>
> The developer said that they are using module LWP in Perl, but he

doesn't
> know what to use in ASP or ASP.NET.
>
> Peter
>
> "london calling" <lo***********@ discussions.mic rosoft.com> wrote in

message
> news:E3******** *************** ***********@mic rosoft.com...
> > Hi Peter,
> > Have a look at the System.Net.Http WebRequest object and use it to

create a
> > form post, you can then read the response and take any action you

require
> >
> > HTH jd
> >
> > "Peter Afonin" wrote:
> >
> >> Hello,
> >>
> >> I have a simple client-side form that is checking the domain

availability
> >> on
> >> the domain registrar's server:
> >>
> >> <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl"
> >> method="post">
> >> <input type="hidden" name="thisPage" value="pispChec kDomain">
> >> <input type="hidden" name="username" value="test">
> >> <input type="hidden" name="password" value="test">
> >> domain_name: <input type="text" name="domain_na me"><br>
> >> <input type="submit" runat="server" id="Submit1" value="Submit

Query"
> >> name="Submit1">
> >> </FORM>
> >>
> >> It sends parameter thisPage with the value pispCheckDomain that
tells the
> >> system to check availability of a domain domain_name.
> >>
> >> The server responds like this: Success: <domain name> is
Available or > >> Success: <domain name> is Unavailable. I can see it on the page
> >> https://www.webnames.ru/scripts/RegTimeSRS.pl
> >>
> >> How can I get these results to my page using ASP.NET? There is no
> >> information that the server returns any parameters, so I need to
> >> construct
> >> the request myself. I usually use Request.QuerySt ring("param") or
> >> request.Form("p aram"), but in this case there is no "param"

specified.
> >> Should be pretty easy task for a web programmer, but I've never

done this
> >> before. This should be similar to querying Whois results.
> >>
> >> I would appreciate your advice.
> >>
> >> Thank you,
> >>
> >> --
> >> Peter Afonin
> >>
> >>
> >>
>
>
>


Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2588
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as I could not configure Apache myself. The REAL problem is that PHPmyAdmin works and sees my test database Wines.... But my PHP program does not!
4
1906
by: s99999999s2003 | last post by:
hi the database "execute" function returns a list of logical results. Each logical result is a list of row tuples, as explained in the documents. everytime i use it to execute various statements, it returns me, for example (, , ) and sometimes , (, ) or () in my call, i give eg (a,b,c) = db.execute(stmt) so that it returns me (, ,
2
1410
by: Kent P. Iler | last post by:
Hi, I am building my first ASP.NET website (I've done quite a few in ASP with windows DNA, but none needing Index server). I need to have a site search, and want the results formatted in a specific way. I have a few ASP.NET books, but they don't even have sections in them (Wrox Professional ASP.NET, etc.). If you know of any online sites with some good references on customizing
4
14402
by: Chris Tremblay | last post by:
I am trying to figure out how to go about retrieving the number of results returned from my queries in SQL server from VB.NET without using a the Select Count(*) query. The method that I was using was the following: Take the query that I am executing, copy the query and turn it into a count query, run the count query, then execute the original query. The reason for this is so that I can implememt public paging on my website. The...
3
2512
by: Grant Schenck | last post by:
Hello, I have a Windows Service developed in C# .NET. I'm making it a remote server and I can, via an IPC Channel, expose methods and call them from a client. However, I now want my remoted object to be able to invoke a method on my server object and given that the object is built in a C# Class DLL shared between the client and server I'm not sure how to get access to the server object from the remoted object. So, what techniques...
2
3850
by: dmagliola | last post by:
Hello all, I'm experiencing a problem with ASP.Net for which I can't find a reasonable explanation, or any information. I'm currently developing an application that, through AJAX, asks the server for updated information to show, and can also send information to the server. To do this, I have an XMLHttpRequest that queries an Asynchronous HTTP
4
8683
by: meendar | last post by:
Hi to all, I just need to get two fields from a table and manipulate the results in next query of a procedure.I planned to code like what you see below, create procedure marks1 as @ sql1 as varchar(50)
6
18258
by: plork | last post by:
hi all i'm calling a web service method and can get it's results just fine however i want to grab the repsonse message from the call is anyone able to tell me how i do this? results = service.getMethod(a, b, c, d) then iterating through for (int i = 0; i < results .Length; i++)
11
1484
by: Armin Zingler | last post by:
"Bill Schanks" <wschanks@gmail.comschrieb Try to execute lvMembers.beginupdate before filling and lvMembers.endupdate
0
9962
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11198
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9609
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7150
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5829
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4647
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.