进行WebAPI 2 JSON发布时找不到HttpRequestBase.GetBufferedInputStream [英] HttpRequestBase.GetBufferedInputStream not found when doing a WebAPI 2 JSON Post

查看:189
本文介绍了进行WebAPI 2 JSON发布时找不到HttpRequestBase.GetBufferedInputStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 使用Visual Studio创建MVC5 WebAPI2项目
  2. 创建了基本的JSON POST
  3. 发布参数导致HttpRequestBase.GetBufferedInputStream找不到失败

适用于:

  1. 带有Visual Studio的Windows

失败:

  1. OSX Xamarin
  2. Gentoo Xamarin

测试应用程序: Mono MVC5 Web API2测试用例

测试过程:

  1. 在xamarin中运行MVC应用程序
  2. 在加载时,页面将在服务器上进行ajax发布.
  3. a)服务器将在失败时返回500错误

  1. run the MVC application in xamarin
  2. On load the page will do a ajax post to the server.
  3. a) server will return a 500 error on failure

b)console.log成功发布arg

b) console.log post arg on success

Error: {
    "Message": "An error has occurred.",
    "ExceptionMessage": "Method 'HttpRequestBase.GetBufferedInputStream' not found.",
    "ExceptionType": "System.MissingMethodException",
    "StackTrace": " at System.Web.Http.WebHost.HttpControllerHandler+LazyStreamContent.get_StreamContent () [0x00008] in :0

                    at System.Web.Http.WebHost.HttpControllerHandler+LazyStreamContent.CreateContentReadStreamAsync () [0x00000] in :0

                    at System.Net.Http.HttpContent+c__async2.MoveNext () [0x00095] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Net.Http/System.Net.Http/HttpContent.cs:159

                    --- End of stack trace from previous location where exception was thrown ---

                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61

                    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201

                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170

                    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142

                    at System.Runtime.CompilerServices.TaskAwaiter`1[System.IO.Stream].GetResult () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372

                    at System.Net.Http.HttpContentExtensions+d__0`1[System.Object].MoveNext () [0x00080] in :0

                    --- End of stack trace from previous location where exception was thrown ---

                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61

                    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201

                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170

                    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142

                    at System.Runtime.CompilerServices.TaskAwaiter`1[System.Object].GetResult () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372

                    at System.Web.Http.ModelBinding.FormatterParameterBinding+d__0.MoveNext () [0x000a5] in :0

                    --- End of stack trace from previous location where exception was thrown ---

                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61

                    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201

                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170

                    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142

                    at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:124

                    at System.Web.Http.Controllers.HttpActionBinding+d__0.MoveNext () [0x000a0] in :0

                    --- End of stack trace from previous location where exception was thrown ---

                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61

                    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201

                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170

                    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142

                    at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:124

                    at System.Web.Http.Controllers.ActionFilterResult+d__2.MoveNext () [0x0008f] in :0

                    --- End of stack trace from previous location where exception was thrown ---

                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61

                    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201

                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170

                    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142

                    at System.Runtime.CompilerServices.TaskAwaiter`1[System.Net.Http.HttpResponseMessage].GetResult () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372

                    at System.Web.Http.Dispatcher.HttpControllerDispatcher+d__1.MoveNext () [0x0018d] in :0 "
}

推荐答案

在向客户端保证我可以编写一个ASP.NET 5 WepAPI应用程序并将其部署到他们的Ubuntu 14.04服务器中之后,我也遇到了这个问题. 是的.

I too had this issue after promising a client I could write an ASP.NET 5 WepAPI application and deploy it in their Ubuntu 14.04 server. Yay.

基本上,您需要升级到最新版本才能正确支持此功能.在Ubuntu上,您可以使用官方的Nightlies仓库.但是请注意,在Ubuntu上,您可能需要使用dpkg列出所有已安装的软件包,并对mono进行grep,并确保完全清除以前的安装(手动安装和安装软件包管理器).尤其是如果您是从源代码安装的,则会遇到此问题.

Basically, you need to upgrade to a bleeding edge version to get this feature supported correctly. On Ubuntu, you can use the official nightlies repository. Note however that, on Ubuntu, you may need to list all installed packages using dpkg and do a grep for mono and make sure that you fully purge previous installations (manual and package-manager installed alike). You'll have this issue especially if you've installed from source.

同样,在Ubuntu上下文中,您可以使用whereis mono跟踪可能存在的任何地方.之所以必须这样做,是因为否则您将发生冲突,因为您的ENV中将有多个版本的mono竞争.

Again, in the context of Ubuntu, you can use whereis mono to track down everywhere that it might be. This must be done because otherwise you're going to have conflicts, as you'll have multiple versions of mono competing in your ENV.

对于OSX和其他平台,您可以找到官方信息以及夜间链接

For OSX and other platforms, you can find official information and links to nightlies here.

同样,对于Ubuntu,以下是将二进制文件添加到源代码中的方法:

Again, for Ubuntu, here's how to add the binary nightlies to your sources:

echo "deb http://download.mono-project.com/repo/debian nightly main" | sudo tee /etc/apt/sources.list.d/mono-nightly.list
sudo apt-get update

这篇关于进行WebAPI 2 JSON发布时找不到HttpRequestBase.GetBufferedInputStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆