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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:53:36+00:00 2026-06-13T00:53:36+00:00

I have MVC-4 Web-API server, and I need to create HTTP client by hand

  • 0

I have MVC-4 Web-API server, and I need to create HTTP client “by hand” (via TCP) to talk with it.

public class UpdateUnitDetailsController : ApiController
{
    // GET api/updateunitdetails
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }

    // GET api/updateunitdetails/5
    public string Get(int id)
    {
        return "value";
    }

    // POST api/updateunitdetails
    public void Post([FromBody]string value)
    {
    }

    // POST api/updateunitdetails
    public void Post()
    {
    }

    // PUT api/updateunitdetails/5
    public void Put(int id, [FromBody]string value)
    {
    }

    // DELETE api/updateunitdetails/5
    public void Delete(int id)
    {
    }
}

I made a simple client and set breakpoints in the server’s controller’s methods. In the client, I send this:

GET /api/updateunitdetails HTTP/1.1
Host: localhost:58743

Content-Type: */*
Content-Length: 10

home=sweet

And it works (the debugger stops in the Get method). But if I change GET to POST, it doesn’t. Moreover, whenever I issue a POST request, I see in the Visual Studio Console this message:

A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Http.dll

What do I miss ?

  • 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-13T00:53:37+00:00Added an answer on June 13, 2026 at 12:53 am

    Use this instead:

    POST /api/updateunitdetails HTTP/1.1
    Host: localhost:58743
    
    Content-Type: application/x-www-form-urlencoded
    
    
    =sweet
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>
All of my datamodels have field DateAdded. When the user (through MVC Web API)
My project consist of: MVC, WEB API solution. I have generated an ADO.NET entity
I have asp.net mvc 4 web application project on my server in IIS Directory.
I just create a new MVC 4 Web API project, and create a new
I have a Spring Web MVC application where i need to use an external
I'm playing with ASP.NET Web API and I have the following: public Guid GetLogon(string
I have a MVC Web Api Controller that uses the [Authorize] attribute at the
Azure web role (MVC 3 project) wont' start with Twilio controller class I have
I have a set of services hosted with WCF Web Api, what I need

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.