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'm building a console application in Ruby. One of the things I'd like it
I'm building a small application that pulls statistics from an API I have no
I am building a WebDAV server class library for .NET and I'm having some
I created a WCF service and Hosted it through console. but when I created
When I create a Console App I can right click on the project in
I am setting out to create an app that will watch a directory for
We are using StructureMap as our Dependency Injection (DI) framework while we are creating
I am working on a weather app, and have everything working perfectly ...Except the
I'm new in C# but not new to coding --being doing it for almost
I have an app I distribute over Cydia. It's nothing hacky, just a GUI

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.