How to add Multipart Form Data parameter on WebAPI help page
Asked Answered
G

0

5

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)
Get answered 7/1, 2015 at 12:45 Comment(2)
im having the same issue. i was wandering whether its better to use model binding but thats seems to add more complexity for something that seems fairly standard. I cant help but thought i would share that i am struggling with a help page for multi part form dataBuffybuford
advice im really struggling with this. thanksGet

© 2022 - 2024 — McMap. All rights reserved.