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

  • SEARCH
  • Home
  • 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 8040133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:47:46+00:00 2026-06-05T03:47:46+00:00

I am writing a console application that needs to perform a POST to an

  • 0

I am writing a console application that needs to perform a POST to an MVC controller. I am using the WebClient class to perform the POST. But I’m having trouble understanding how to add arrays to the message body.

For simple parameters, it seems to work if I do this:

         using (var client = new WebClient())
        {

            var values = new NameValueCollection 
            { 
                { "userName", "userName" },
                { "password", "passwordGoesHere"}

            };
            byte[] responseArray = client.UploadValues(String.Format("{0}/Mobile/StartSession", serverAddress), values);
            Debug.WriteLine(String.Format("\r\nResponse received was :\n{0}\n", Encoding.ASCII.GetString(responseArray)));

        }

I was trying to find how to pass arrays in the message body when using WebClient (for calling one of the other methods). I came across this solution: POST'ing arrays in WebClient (C#/.net)

It appears the solution actually passes parameters in the query string (and not in the message body). This seems to work in any case, as the HttpPost method on the MVC controller is still receiving the correct information. However, another method requires that I pass an image as an array of bytes. This is too large to be passed in the querystring and so the call fails.

So my question is, using the code I provided above, how can I add arrays in there as well. So an array of bytes for example, but also an array of strings.

If any one can provide me with a solution it would be much appreciated, or if I’m incorrect in my thinking please let me know.

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-06-05T03:47:47+00:00Added an answer on June 5, 2026 at 3:47 am

    Instead of using array of bytes maybe you should POST a file in the same way files are uploaded from browser from file inputs. This way you will save some transfered bytes, but you have to use HttpWebRequest instead of WebClient. More about this solution is here:

    Upload files with HTTPWebrequest (multipart/form-data)

    You upload bytes as “multipart/form-data” content type. On the server you will receive the streams of bytes in Request.Files collection.

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

Sidebar

Related Questions

I'm writing a console application under Ubuntu that uses the serial port. It needs
I'm writing a small c# console application that needs to interogate Websphere Application Server
I’m writing a console application that has a custom logger in it. The logger
I'm writing a console application that will be deployed with an installation of an
I am writing a console application that will do two tasks. The app will
I am writing a console application in python that will consist of a handful
I am writing a C# application that needs to communicate with another application written
I'm currently writing a c++ console application that grabs the mouse position at regular
I'm writing an application that needs to hold around forty 44 kb JPEGs in
I'm writing a console application Windows that creates some objects in the main thread

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.