Webrequest doesn't work...but direct Get post does.

Last post 11-06-2009 10:28 AM by codeaholic. 3 replies.

Sort Posts:

  • Webrequest doesn't work...but direct Get post does.

    11-05-2009, 3:18 PM
    • Participant
      1,122 point Participant
    • codeaholic
    • Member since 04-15-2005, 12:30 PM
    • Posts 424

    Ok, stumped, I'm completely stumped.  This code doesn't crash but the response does not work or match the same response you get when you go directly to the url with your browser.  Does anyone know why? 

    https://www.moneybookers.com/app/email_check.pl?email=demo@moneybookers.com&cust_id=4444597&password=098f6bcd4621d373cade4e832627b4f6

     

     'Process button event for Email Check
    Dim ErrMsg As String = ""

     

    Dim FinalResponse As String

     

    Dim postData As String

    postData =

    "?email=demo@moneybookers.com&cust_id=4444597&password=098f6bcd4621d373cade4e832627b4f6"

     

    'Tests ok https://www.moneybookers.com/app/email_check.pl?email=demo@moneybookers.com&cust_id=4444597&password=098f6bcd4621d373cade4e832627b4f6

     

    'Also Tests ok

     

     

    'https://www.moneybookers.com/app/email_check.pl?email=support@comcity.com&cust_id=12769592&password=bdbaff4c39ec8f3127bc6ce8f36cf1ee

     

    Dim CheckURL As String = "https://www.moneybookers.com/app/email_check.pl"

     

    'Check if Domain is registered and active

     

    'Basic check to see if domain is active and registered

     

     

    Dim XmlHttp As HttpWebRequestTry

    XmlHttp = WebRequest.Create(

     

    ErrMsg =

    String.Format(CheckURL, postData))Catch ex As Exception"Failed " & Err.Number & ", " & Err.Description & "<p>HTTPWebRequest Failed on Create, Email Check.<br> "

    ErrMsg = ErrMsg &

    "Print this page out and contact SalesCart for more information @ support.salescart.com."

    ErrorOut(ErrMsg)

     

    Exit Sub

     

    End Try

     

    'Set the Method, contenttype, and contentlength of the GetRequestStream

    XmlHttp.Method =

    "GET"

     

    'Handle Response

     

     

    Dim MyResponse As HttpWebResponse = CType(XmlHttp.GetResponse(), HttpWebResponse)'Now, we read the response (the string), and output it.

     

     

    Response.Write(_Answer.ReadToEnd())

    Response.End()

    Dim Answer As Stream = MyResponse.GetResponseStreamDim _Answer As StreamReader = New StreamReader(Answer)

  • Re: Webrequest doesn't work...but direct Get post does.

    11-06-2009, 9:04 AM
    • Participant
      1,122 point Participant
    • codeaholic
    • Member since 04-15-2005, 12:30 PM
    • Posts 424

    Bueller...Bueller....Bueller.

    Nobody? 

  • Re: Webrequest doesn't work...but direct Get post does.

    11-06-2009, 9:29 AM
    Answer
    • Contributor
      2,494 point Contributor
    • SSA
    • Member since 05-07-2009, 7:16 PM
    • Amsterdam, The Nederlands
    • Posts 411

    I used your URL in below c# function and it gives me same output:

    Check it in VB:

    protected void Button1_Click(object sender, EventArgs e)
        {
                #region make URL

                string Url = "https://www.moneybookers.com/app/email_check.pl?email=demo@moneybookers.com&cust_id=4444597&password=098f6bcd4621d373cade4e832627b4f6";

                #endregion

                                   
                
                   
                    /**
                     * Make request
                     **/  
                    HttpWebRequest objWebRequest =(HttpWebRequest) WebRequest.Create(Url);

                    objWebRequest.ContentType = "text/plain";

                    objWebRequest.Method = "Get";

                    objWebRequest.Timeout = 1000;

                    /**
                     * Get reponse
                     **/
                    
                    HttpWebResponse objWebResponse = (HttpWebResponse)objWebRequest.GetResponse();

                    if (objWebResponse.StatusCode == HttpStatusCode.OK)
                    {


                        System.IO.StreamReader responseStream = new System.IO.StreamReader(objWebResponse.GetResponseStream());


                        /**
                         * Parse response
                         **/



                        string strReply = responseStream.ReadToEnd();

                        txtName.Text = strReply; // value kept in textbox

                        responseStream.Close();
                    }

                   
                    objWebResponse.Close();
        }

  • Re: Webrequest doesn't work...but direct Get post does.

    11-06-2009, 10:28 AM
    • Participant
      1,122 point Participant
    • codeaholic
    • Member since 04-15-2005, 12:30 PM
    • Posts 424

    Thanks...

    Yes, if I cancatonate the string before hand it works fine... 

Page 1 of 1 (4 items)