Getting results from the server

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default 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
    [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]

    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


    Peter Afonin Guest

  2. Similar Questions and Discussions

    1. #13035 [Com]: 404 on a .php results in SERVER ERROR when using php as a cgi
      ID: 13035 Comment by: servers at dedicated dot com Reported By: sbeam at ne dot mediaone dot net Status: No...
    2. Select Qry: Differing results via Access & ADO (& SQL Server)
      I have a query which produces different results in the Access query builder and in an ASP page (via ADO) An example of the query is:...
    3. get results from a remote server using post
      You can use curl functions. Very easy. "Kram" <kram.techie@NOSPAM.ntlworld.com> wrote in message...
    4. #26235 [Opn->Csd]: Bad results in yp_first/yp_next with a Solaris NIS server
      ID: 26235 Updated by: iliaa@php.net Reported By: benoit dot sibaud at rd dot francetelecom dot com -Status: ...
    5. Combining Index Server and SQL Server search results
      I'm just about to start a project that needs to combine the results of a SQL Server query with the results of an Index Server query. The basic idea...
  3. #2

    Default RE: Getting results from the server

    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
    > [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    >
    > 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
    >
    >
    >
    london calling Guest

  4. #3

    Default Re: Getting results from the server

    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" <londoncalling@discussions.microsoft.com> wrote in message
    news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    >>
    >> 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
    >>
    >>
    >>

    Peter Afonin Guest

  5. #4

    Default Re: Getting results from the server

    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" <londoncalling@discussions.microsoft.com> wrote in message
    > news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    > >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    > >>
    > >> 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
    > >>
    > >>
    > >>
    >
    >
    >
    london calling Guest

  6. #5

    Default Re: Getting results from the server

    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
    [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url], 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,
    [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url], so I'm not sure how it will
    read it. I guess I have to try.

    Thanks again,

    Peter

    "london calling" <londoncalling@discussions.microsoft.com> wrote in message
    news:F1BD7C68-A94B-4D42-8319-9CA903CB7CEB@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    >> message
    >> news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    >> >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    >> >>
    >> >> 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
    >> >>
    >> >>
    >> >>
    >>
    >>
    >>

    Peter Afonin Guest

  7. #6

    Default Re: Getting results from the server

    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
    [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]. How do I get back to my page
    to read the results?

    Thank you,

    Peter

    "london calling" <londoncalling@discussions.microsoft.com> wrote in message
    news:F1BD7C68-A94B-4D42-8319-9CA903CB7CEB@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    >> message
    >> news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    >> >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    >> >>
    >> >> 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
    >> >>
    >> >>
    >> >>
    >>
    >>
    >>

    Peter Afonin Guest

  8. #7

    Default Re: Getting results from the server

    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" <londoncalling@discussions.microsoft.com> wrote in message
    news:F1BD7C68-A94B-4D42-8319-9CA903CB7CEB@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    message
    > > news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    > > >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    > > >>
    > > >> 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
    > > >>
    > > >>
    > > >>
    > >
    > >
    > >

    Peter Afonin Guest

  9. #8

    Default Re: Getting results from the server

    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" <londoncalling@discussions.microsoft.com> wrote in message
    > news:F1BD7C68-A94B-4D42-8319-9CA903CB7CEB@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    > message
    > > > news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    > > > >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    > > > >>
    > > > >> 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
    > > > >>
    > > > >>
    > > > >>
    > > >
    > > >
    > > >
    >
    >
    >
    london calling Guest

  10. #9

    Default Re: Getting results from the server

    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
    > [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]. How do I get back to my page
    > to read the results?
    >
    > Thank you,
    >
    > Peter
    >
    > "london calling" <londoncalling@discussions.microsoft.com> wrote in message
    > news:F1BD7C68-A94B-4D42-8319-9CA903CB7CEB@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    > >> message
    > >> news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    > >> >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    > >> >>
    > >> >> 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
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>
    >
    >
    >
    london calling Guest

  11. #10

    Default Re: Getting results from the server

    Thank you very much, I really appreciate your help! I'll try this today.

    Peter

    "london calling" <londoncalling@discussions.microsoft.com> wrote in message
    news:5EA8B897-9462-45FE-98C8-D5DBA10811D3@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    message
    > > news:F1BD7C68-A94B-4D42-8319-9CA903CB7CEB@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    > > message
    > > > > news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    > > > > >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    > > > > >>
    > > > > >> 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
    > > > > >>
    > > > > >>
    > > > > >>
    > > > >
    > > > >
    > > > >
    > >
    > >
    > >

    Peter Afonin Guest

  12. #11

    Default Re: Getting results from the server

    It worked, thank you!

    I still cannot make it work with SSL. I've found an article that provides a
    workaround ([url]http://support.microsoft.com/Default.aspx?scid=kb;en-us;823177[/url]),
    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" <londoncalling@discussions.microsoft.com> wrote in message
    news:5EA8B897-9462-45FE-98C8-D5DBA10811D3@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    >> message
    >> news:F1BD7C68-A94B-4D42-8319-9CA903CB7CEB@microsoft.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" <londoncalling@discussions.microsoft.com> wrote in
    >> message
    >> > > news:E32E58AD-155E-47EE-A8C1-333078EBB947@microsoft.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
    >> > > >> [url]https://www.webnames.ru/scripts/RegTimeSRS.pl[/url]
    >> > > >>
    >> > > >> 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
    >> > > >>
    >> > > >>
    >> > > >>
    >> > >
    >> > >
    >> > >
    >>
    >>
    >>

    Peter Afonin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139