2

I am trying to get the raw data POSTed to an ASP.NET Web API 2 app. I am running Mono 4.2.3 on an Ubuntu 14 server.

I have a very basic HTTP POST handler set up as such:

[HttpPost]
public async Task<string> PostResponse()
{
    string postData = await Request.Content.ReadAsStringAsync();
    return postData;
}

and it works when I call it from the Visual Studio 2015 debugger (ASP.NET 4.5.2, IIS 10 Express) using curl:

$ curl -X POST http://localhost:53385/api/calc/ -d 'hello stackoverflow'
hello stackoverflow

However, if I run it in Mono (using xsp4), I get this:

$ curl -X POST http://trusty-test:1080/api/calc/ -d 'hello stackoverflow'
{"Message":"An error has occurred."}

Is Mono just broken here or am I missing something?

Edited to add:

GET responses work fine.

I have tried running xsp4 with xsp4 --verbose, xsp4 --verbose --loglevels=all

Additionally, I have tried bypassing the /usr/bin/xsp4 script and starting xsp4 directly using mono --debug "/usr/lib/mono/4.5/xsp4.exe", and also attaching gdb using gdb --args /usr/bin/mono --debug "/usr/lib/mono/4.5/xsp4.exe"

None of these produced any useful output.

chui101
  • 53
  • 1
  • 5
  • 1
    Have you tried attaching a debugger (e.g. `gdb`) to the xsp4 instance? You could check if anything gets printed to the debug output. – cbr Apr 04 '16 at 15:09
  • Sorry, should have mentioned that. I haven't attached GDB but I have run `xsp4` with `--verbose`, `--loglevels=all`, and bypassing the xsp script and getting mono debug output directly calling `mono --debug '/usr/lib/mono/4.5/xsp.exe'`, none of which produced any useful output. – chui101 Apr 04 '16 at 15:17
  • 1
    See if GDB gives you anything. – cbr Apr 04 '16 at 15:31
  • Intiially got constant SIGXCPU interrupts, but apparently this is is normal. After telling gdb `handle SIGXCPU SIG33 SIG35 SIGPWR nostop noprint` (per Xamarin docs), I didn't see anything else useful... – chui101 Apr 04 '16 at 15:38
  • 1
    Add proper exception handling and logging to see what is actually going wrong. Web API doesn't return exception details in failure responses for security reasons – Panagiotis Kanavos Apr 04 '16 at 15:47
  • 2
    @PanagiotisKanavos Isn't there a way to turn them on for debugging? – cbr Apr 04 '16 at 16:58
  • 1
    @PanagiotisKanavos Thanks, I didn't know they were off by default... that definitely explains the lack of any (useful) error messages! [This](http://stackoverflow.com/questions/34033977/httprequestbase-getbufferedinputstream-not-found-when-doing-a-webapi-2-json-post) is apparently the underlying issue. – chui101 Apr 04 '16 at 17:36

0 Answers0