Asp.net mvc 将文件从Android上载到VB.NET MVC API

Asp.net mvc 将文件从Android上载到VB.NET MVC API,asp.net-mvc,vb.net,file-upload,asp.net-web-api,Asp.net Mvc,Vb.net,File Upload,Asp.net Web Api,我正在尝试使用VB.NET MVC 4 web API将图像从我的移动应用程序上载到web服务构建中。这个移动应用程序可以成功地上传到我测试过的php api,所以我知道问题出在我的web服务上。我在网上搜索过,没有找到任何上传文件的工作样本,如有任何建议,将不胜感激 代码: 错误: 没有MediaTypeFormatter可用于读取“Pic”类型的对象 来自媒体类型为“多部分/表单数据”的内容 例外类型: System.InvalidOperationException异常 堆栈跟踪: 在Sy

我正在尝试使用VB.NET MVC 4 web API将图像从我的移动应用程序上载到web服务构建中。这个移动应用程序可以成功地上传到我测试过的php api,所以我知道问题出在我的web服务上。我在网上搜索过,没有找到任何上传文件的工作样本,如有任何建议,将不胜感激

代码:

错误:

没有MediaTypeFormatter可用于读取“Pic”类型的对象 来自媒体类型为“多部分/表单数据”的内容

例外类型:

System.InvalidOperationException异常

堆栈跟踪:

在System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent内容,类型,IEnumerable
1格式化程序,IFormatterLogger格式化程序记录器)\r\n在System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent内容,类型,IEnumerable
1格式化程序,IFormatterLogger格式化程序记录器)\r\n位于System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage请求,类型类型,IEnumerable
1格式化程序,IFormatterLogger格式化程序记录器)\r\n位于System.Web.Http.ModelBinding.FormatterParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider,HttpActionContext actionContext,CancellationToken CancellationToken)\r\n位于System.Web.Http.Controllers.HttpActionBinding.c\u DisplayClass1.b\u 0(HttpParameterBinding parameterBinder)\r\n位于System.Linq.Enumerable.where SelectArrayInterator
2.MoveNext()\r\n在System.Threading.Tasks.TaskHelpers.IterateImpl(IEnumerator`1 enumerator,CancellationToken CancellationToken)}

和-两者都是C语言,但您可以使用和-两者都是C语言,但您可以使用
Imports System.IO
Imports System.Net.Http
Public Class Pic

 Public Property pix As FileUpload

Public Function addPic() As String
    Try

         Dim savedFile As String
         savedFile = Path.GetFileName(Me.pix.PostedFile.FileName)
         Me.pix.PostedFile.SaveAs("C:\tmp" + savedFile)

    Catch exp As Exception
        'Response.Write(exp.Message)
    End Try

   End Function
End Class
Public Function Post()            
    Dim value1 As String = System.Web.HttpContext.Current.Request.Form("value1")

        Dim image1 As HttpPostedFile = System.Web.HttpContext.Current.Request.Files("value2")

        Dim filename As String = System.IO.Path.GetFileName(image1.FileName)

        pix.SaveAs("c:\tmp\" + filename)


    End Function