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 1001243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:38:20+00:00 2026-05-16T07:38:20+00:00

I am building a console application that gathers some data and then sends it

  • 0

I am building a console application that gathers some data and then sends it to a php page through a POST request. This is my C# code:

HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("http://localhost/log.php");
Request.Method = "POST";
Request.ContentType = "application/x-www-form-urlencoded";
string PostData = "data=" + UserOutput;
Request.ContentLength = PostData.Length;

StreamWriter stOut = new StreamWriter(Request.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(PostData);
stOut.Close();

And the PHP page (log.php):

<?php

file_put_contents('log.txt', $_POST['data']);

?>

Note I am only using file_put_contents to test if everything works OK, it is not what I want to end up doing.

The length of the post data to send is over 2,000 characters long, and the correct content length is returned by Request.ContentLength = PostData.Length;, so that’s not the problem. But whenever I try this it is only sending the first 46 characters of my POST data.

I do have to admit at this point that I copied most of the code, as I am not very experienced in C#.

Any help would be great, thanks.

  • 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-05-16T07:38:21+00:00Added an answer on May 16, 2026 at 7:38 am

    Is the 47th character “&” by any chance? You’ve claimed that your data is URL-encoded, but you haven’t done any URL-encoding in the code you’ve provided. If there’s an “&” that would indicate to PHP that it was about to accept a new form parameter…

    One way to verify this (apart from using HttpUtility.UrlEncode) would be to use Fiddler or Wireshark to see what’s actually going on at the network level.

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

Sidebar

Related Questions

I recently started building a console version of a web application. I copied my
I have a C# project building winexe that startup without console window. However, I
When building some of my PHP apps, a lot of the functionality could be
I'm building a calculator, and am using the following: jQuery(function($) { $('#Quantity').keyup(function() { console.log($(this).val());
Building a client-side swing application what should be notified on a bus (application-wide message
Building the same project (without any changes) produces binary different exe-files: some small regions
Im building a web application which is a process management app. Several different employee
I’m having some difficulties while trying to consume an unmanaged-code dll from my application
I'm building a .NET component that will call an external web service. I used
I am building a universal app that uses a UISplitViewController for the iPad, and

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.