I have a ASP.NET MVC project that needs an API controller which will accept a posted multipart form and extract the data out of the <formroot>
xml tag (which is highlighted)
I am struggling on getting this working any help would be greatly appreciated
Currently I have a controller called UploadController and this is the code I currently have
public class UploadController : ApiController
{
public async Task<HttpResponseMessage> PostFormData()
{
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.BadRequest);
}
string root = HttpContext.Current.Server.MapPath("~/App_Data");
var provider = new MultipartFormDataStreamProvider(root);
try
{
//Need to get the data from within the formroot tag
return Request.CreateResponse(HttpStatusCode.OK);
}
catch (Exception e)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
}
}
}
I am unsure the best way to get the data from within the formroot, also forgive me if any of the code above is not correct.