title: Web API 2 POST-Request not working on mono
body: <p>I want to write a REST-Server with WEB API 2 on Linux-machine with mono without IIS or something.</p>
  
  <p>What i have done:</p>
  
  <ol>
  <li>Created a Empty C# Console Application</li>
  <li><p>Added the Nuget-Package: Microsoft.AspNet.WebApi.OwinSelfHost,        WebApi.Cors for handling CORS-Request</p></li>
  <li><p>Then i created a Startup.cs for defining my Config;</p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          app.UseWebApi(ConfigureWebApi());
      }
  
      private HttpConfiguration ConfigureWebApi()
      {
  
          var config = new HttpConfiguration();
          var cors = new EnableCorsAttribute("*", "*", "*");
          config.EnableCors(cors);
          //Attribute Routing aktivieren
          config.MapHttpAttributeRoutes();
          config.Routes.MapHttpRoute(
  
              "DefaultApi",
  
              "api/{controller}/{id}",
  
              new { id = RouteParameter.Optional });
  
          return config;
      }
  }
  </code></pre></li>
  <li><p>Edit my Program.cs to act like a server</p>
  
  <pre><code>    class Program
      {
      static void Main(string[] args)
      {
          string baseUrl = "http://*:5000";
          using (WebApp.Start&lt;Startup&gt;(baseUrl))
          {
              Console.WriteLine("Press Enter to quit.");
              Console.ReadKey();
  
          }
      }
  }
  </code></pre></li>
  <li><p>In this step i add a Model Class Book</p>
  
  <pre><code>public class Book
  {
      public String Name { get; set; }
      public String Author { get; set; }
  
      public int Id { get; set; }
  }
  </code></pre></li>
  <li><p>And finaly the BooksController which should handle the requests:</p>
  
  <pre><code>public class BooksController : ApiController
  {
      public BooksController()
      {}
  
      public async Task&lt;IHttpActionResult&gt; Get()
      {
          List&lt;Book&gt; list = new List&lt;Book&gt;();
          list.Add(new Book() { Name = "myBook",Author = "John" ,Id=1});
          list.Add(new Book() { Name = "myBook2",Author = "Peter",Id=2 });
          return Ok(list);
      }
  
      public async Task&lt;IHttpActionResult&gt; Post(Book requestData)
      {
          return Created&lt;Book&gt;("api/books/" + requestData.Id, requestData);
      }
  }
  </code></pre></li>
  </ol>
  
  <p>I started this whole application on a Linux-machine with mono-4.0.2
  And test the app with the "postman"-Application to create the different HTTP-Requests.</p>
  
  <p>I've testet the server with a GET-Request to /api/books and it worked!</p>
  
  <p>My problem is when i do a POST-Request i get a "500 Internal Server Error" 
  Response. </p>
  
  <p>My POST-Request look like this 
  <a href="https://i.stack.imgur.com/DPO5R.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DPO5R.jpg" alt="enter image description here"></a></p>
  
  <p>The strange thing is that when i run my app on a windows machine on the .NET Framework the POST-Request is working without problem!</p>
  
  <p>I don't understand why its not working on mono! And hope someone knows the answer.</p>