我正在从POSTMAN向服务器发送请求:
Content-Type: multipart/form-data
WebApi方法:
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Web;
using System.Web.Http;
using System.Web.Http.Cors;
namespace AddMobileAPI.Controllers
{
[EnableCors(origins: "*", headers: "*", methods: "*")]
[RoutePrefix("api/alarms")]
public class AlarmsController : ApiController
{
[HttpPost]
[Route("uploadImage")]
public IHttpActionResult UploadImageAsync()
{
var testValue = HttpContext.Current.Request.Form["test"];
return Ok("Success !!");
}
}
}
此代码在此行给我一个错误
var testValue = HttpContext.Current.Request.Form["test"];
因为当前为空