How to add Multipart Form Data parameter on WebAPI help page

老子叫甜甜 提交于 2019-12-10 14:09:15

问题


Please help me to add a multipart/form data parameter on api help page.

I'm using Microsoft.AspNet.WebApi.HelpPage.VB 5.2.2.

I want to add CustomerName, fdStreet1, fdStreet2 parameter information on to the api help page. How can I do this?

Here's what I have so far.

 <HttpPost> _
<ResponseType(GetType(TestModel))> _
<Route("TestAdd")> _
Public Function TestAdd() As IHttpActionResult

    Dim ServerUploadFolder = HttpContext.Current.Server.MapPath("~/Uploaded/")
    If Not Request.Content.IsMimeMultipartContent Then
        Throw New HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType))
    End If

    Dim streamProvider = New CustomMultipartFormDataStreamProvider(ServerUploadFolder)
    Request.Content.ReadAsMultipartAsync(streamProvider)

    'Read form data
    Dim _testModel As New TestModel
    _testModel.fdCustomerName = streamProvider.FormData("CustomerName")
    _testModel.fdStreet1 = streamProvider.FormData("fdStreet1")
    _testModel.fdStreet2 = streamProvider.FormData("fdStreet2")

    Return Json(_testModel)

来源:https://stackoverflow.com/questions/27819829/how-to-add-multipart-form-data-parameter-on-webapi-help-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!