473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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="pispCheckDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
request.Form("param"), 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 1904
Hi Peter,
Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
request.Form("param"), 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.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi Peter,
Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
request.Form("param"), 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 (httpWebResponse) object
contains among otherthings, a method called GetResponseStream which is a
System.IO.Stream containing the page output.

Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi Peter,
Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
request.Form("param"), 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.microsoft.com> wrote in message
news:F1**********************************@microsof t.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 (httpWebResponse) object
contains among otherthings, a method called GetResponseStream which is a
System.IO.Stream containing the page output.

Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in
message
news:E3**********************************@microsof t.com...
> Hi Peter,
> Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
>> request.Form("param"), 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.microsoft.com> wrote in message
news:F1**********************************@microsof t.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 (httpWebResponse) object
contains among otherthings, a method called GetResponseStream which is a
System.IO.Stream containing the page output.

Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in
message
news:E3**********************************@microsof t.com...
> Hi Peter,
> Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
>> request.Form("param"), 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=YouPostedOk"
Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Create(url)
objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/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.microsoft.com> wrote in message
news:F1**********************************@microsof t.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 (httpWebResponse) object
contains among otherthings, a method called GetResponseStream which is a
System.IO.Stream containing the page output.

Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in message news:E3**********************************@microsof t.com...
Hi Peter,
Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
> <input type="hidden" name="username" value="test">
> <input type="hidden" name="password" value="test">
> domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
> request.Form("param"), 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("DoPostToServer")
Dim sResponseString As String = ""

Dim myFormBytes() As Byte =
Text.ASCIIEncoding.ASCII.GetBytes(formContents)

Dim myRequest As Net.HttpWebRequest = Net.WebRequest.Create(postUrl)
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.Method = "POST"
myRequest.Timeout = Me.TimeOutMs
myRequest.ContentLength = myFormBytes.Length

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

Try
outputStream = myRequest.GetRequestStream()
outputStream.Write(myFormBytes, 0, myFormBytes.Length)
Catch ex As Exception
failure = True
Debug.WriteLine(ex.StackTrace + " " + ex.Message)
Finally
If Not outputStream Is Nothing Then
outputStream.Close()
End If
End Try

Dim myResponse As Net.HttpWebResponse
Dim myStreamReader As IO.StreamReader
Dim inputStream As IO.Stream

If Not failure Then
Dim responseSring As String
Try
myResponse = myRequest.GetResponse
inputStream = myResponse.GetResponseStream
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.Close()
End If
If Not myResponse Is Nothing Then
myResponse.Close()
End If
End Try
End If
Debug.WriteLine(sResponseString)
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=YouPostedOk"
Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Create(url)
objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/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.microsoft.com> wrote in message
news:F1**********************************@microsof t.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 (httpWebResponse) object
contains among otherthings, a method called GetResponseStream which is a
System.IO.Stream containing the page output.

Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in message news:E3**********************************@microsof t.com...
> Hi Peter,
> Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
>> request.Form("param"), 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

myWebRequestObject.AllowAutoRedirect = 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.microsoft.com> wrote in message
news:F1**********************************@microsof t.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 (httpWebResponse) object
contains among otherthings, a method called GetResponseStream which is a
System.IO.Stream containing the page output.

Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in
message
news:E3**********************************@microsof t.com...
> Hi Peter,
> Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
>> <input type="hidden" name="username" value="test">
>> <input type="hidden" name="password" value="test">
>> domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
>> request.Form("param"), 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.microsoft.com> wrote in message
news:5E**********************************@microsof t.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("DoPostToServer")
Dim sResponseString As String = ""

Dim myFormBytes() As Byte =
Text.ASCIIEncoding.ASCII.GetBytes(formContents)

Dim myRequest As Net.HttpWebRequest = Net.WebRequest.Create(postUrl) myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.Method = "POST"
myRequest.Timeout = Me.TimeOutMs
myRequest.ContentLength = myFormBytes.Length

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

Try
outputStream = myRequest.GetRequestStream()
outputStream.Write(myFormBytes, 0, myFormBytes.Length)
Catch ex As Exception
failure = True
Debug.WriteLine(ex.StackTrace + " " + ex.Message)
Finally
If Not outputStream Is Nothing Then
outputStream.Close()
End If
End Try

Dim myResponse As Net.HttpWebResponse
Dim myStreamReader As IO.StreamReader
Dim inputStream As IO.Stream

If Not failure Then
Dim responseSring As String
Try
myResponse = myRequest.GetResponse
inputStream = myResponse.GetResponseStream
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.Close()
End If
If Not myResponse Is Nothing Then
myResponse.Close()
End If
End Try
End If
Debug.WriteLine(sResponseString)
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=YouPostedOk"
Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Create(url)
objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/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.microsoft.com> wrote in message news:F1**********************************@microsof t.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 (httpWebResponse) object
contains among otherthings, a method called GetResponseStream which is
a System.IO.Stream containing the page output.

Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in

message
> news:E3**********************************@microsof t.com...
> > Hi Peter,
> > Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
> >> <input type="hidden" name="username" value="test">
> >> <input type="hidden" name="password" value="test">
> >> domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
> >> request.Form("param"), 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
It worked, thank you!

I still cannot make it work with SSL. I've found an article that provides a
workaround (http://support.microsoft.com/Default...;en-us;823177),
but for some reason couldn't make it work yet.

It's OK, since in my case SSL is not necessary.

Regards,

Peter

"london calling" <lo***********@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.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("DoPostToServer")
Dim sResponseString As String = ""

Dim myFormBytes() As Byte =
Text.ASCIIEncoding.ASCII.GetBytes(formContents)

Dim myRequest As Net.HttpWebRequest =
Net.WebRequest.Create(postUrl)
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.Method = "POST"
myRequest.Timeout = Me.TimeOutMs
myRequest.ContentLength = myFormBytes.Length

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

Try
outputStream = myRequest.GetRequestStream()
outputStream.Write(myFormBytes, 0, myFormBytes.Length)
Catch ex As Exception
failure = True
Debug.WriteLine(ex.StackTrace + " " + ex.Message)
Finally
If Not outputStream Is Nothing Then
outputStream.Close()
End If
End Try

Dim myResponse As Net.HttpWebResponse
Dim myStreamReader As IO.StreamReader
Dim inputStream As IO.Stream

If Not failure Then
Dim responseSring As String
Try
myResponse = myRequest.GetResponse
inputStream = myResponse.GetResponseStream
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.Close()
End If
If Not myResponse Is Nothing Then
myResponse.Close()
End If
End Try
End If
Debug.WriteLine(sResponseString)
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=YouPostedOk"
Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Create(url)
objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/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.microsoft.com> wrote in
message
news:F1**********************************@microsof t.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 (httpWebResponse) object
> contains among otherthings, a method called GetResponseStream which is
> a
> System.IO.Stream containing the page output.
>
> Read this stream using a Syatem.IO.StreamReader 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.microsoft.com> wrote in

message
> > news:E3**********************************@microsof t.com...
> > > Hi Peter,
> > > Have a look at the System.Net.HttpWebRequest 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="pispCheckDomain">
> > >> <input type="hidden" name="username" value="test">
> > >> <input type="hidden" name="password" value="test">
> > >> domain_name: <input type="text" name="domain_name"><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.QueryString("param") or
> > >> request.Form("param"), 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 #11

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

Similar topics

3
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...
4
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...
2
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...
4
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...
3
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...
2
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...
4
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...
6
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 =...
11
by: Armin Zingler | last post by:
"Bill Schanks" <wschanks@gmail.comschrieb Try to execute lvMembers.beginupdate before filling and lvMembers.endupdate
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...

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.