Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9257883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:15:36+00:00 2026-06-18T12:15:36+00:00

I have a small problem with HttpWebRequest in my wp 7.1 application. The application

  • 0

I have a small problem with HttpWebRequest in my wp 7.1 application. The application sends some game stats data to the php server by POST -method, but server doesn’t fetch it. The $_POST array stays empty. With the aid of the WireShark I can see the data is in the packet sent to the server, but server doesn’t receive any.

Here is the code of the method by which the data is sent:

    private void SendStatisticsToServer()
    {
        if (this.stat.Name == String.Empty || Object.ReferenceEquals(this.stat.Name, null))
        {
            this.OnEmptyNameEvent();
        }
        else
        {
            HttpWebRequest request = WebRequest.Create(ADDRESS) as HttpWebRequest;
            request.Method = "POST";
            request.ContentType = "text/plain";
            request.AllowReadStreamBuffering = false;

            request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallBack), request);
        }
    }

    private void GetRequestStreamCallBack(IAsyncResult requestRes)
    {
        StringBuilder builder = new StringBuilder("user=");
        builder.Append(this.stat.Name);
        builder.Append("&won=");
        builder.Append(this.stat.Won == true ? "1" : "0");
        builder.Append("&scores=");
        builder.Append(this.stat.Scores.ToString());

        Byte[] byteArray = Encoding.UTF8.GetBytes(builder.ToString());

        HttpWebRequest request = requestRes.AsyncState as HttpWebRequest;
        Stream stream = request.EndGetRequestStream(requestRes);
        stream.Write(byteArray, 0, byteArray.Length);
        stream.Flush();
        stream.Close();

        request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
    }

    private void GetResponseCallback(IAsyncResult requestRes)
    {
        HttpWebRequest request = requestRes.AsyncState as HttpWebRequest;

        HttpWebResponse response = request.EndGetResponse(requestRes) as HttpWebResponse;
        Stream stream = response.GetResponseStream();
        StreamReader streamRead = new StreamReader(stream);
        String responseString = streamRead.ReadToEnd();
        stream.Close();
        streamRead.Close();

        response.Close();
        this.OnExitButtonPressedEvent(ButtonType.Exit);
    }

(I’m sorry for the code with no comments, but I think it’s self-explanatory )

As you can see, it’s almost copy-past from the msdn.

And here is the php -server code:

    <?php
     header('Content-type: text/plain'); 
     // HTTP/1.1
     header("Cache-Control: no-store, no-cache, must-revalidate");
     // HTTP/1.0
     header("Pragma: no-cache");
     $logfile = 'postdata.txt';
     $firstData = $_POST["user"];
     $secondData = $_POST["won"];
     $thirdData = $_POST["scores"];
     $file = fopen($logfile, "a+");

     fwrite($file, "Post received - data: firstData=". $firstData . "   
     secondData=" . $secondData . " thirdData=" . $thirdData . "\r\n");
     fclose($file);

     ?>

As you can see, this server doesn’t do much – only receiving the data and pushing it into the log -file.

it is definitely not a server’s bug, since the old application written in Qt works fine under the same conditions and the $_POST array is not empty.

Could you, please, tell me, where could be a possible error?

The target platform is WP 7.1.

Thank you beforehand for your answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:15:37+00:00Added an answer on June 18, 2026 at 12:15 pm

    I’m going to have to do this as an answer, but I’m not entirely sure this is correct. I believe for a text/plain post, the format of the parameters is:

    user=d
    won=1
    scores=3
    

    If the you do application/x-www-form-urlencoded, then you would go with

    user=d&won=1&scores=3
    

    There’s also a possibility PHP doesn’t support text/plain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem, I want to load data from a PHP file
I have a small problem with my tweets script. But for some reason, I
I have a small problem. My Java application holds some native resources. I want
I have a small problem... if I use the php function to convert a
I am generating new xml file using perl script but I have small problem,
I have small problem with mysql. I have data in table and I want
i have small problem i.e. their is one celltable with lot of data it
I have small problem. I'm trying to work on an XML file, but the
I have a small problem but cannot figure out why. On my django shell:
I have small problem but I can't just find an easy answer.I feel stupid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.