0

I'm sending a request to server from POSTMAN :

enter image description here

Content-Type: multipart/form-data

WebApi method:

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 !!");
        }
    }
}

This Code give me an error at this Line

var testValue = HttpContext.Current.Request.Form["test"];

because the Current is null

Dev
  • 125
  • 2
  • 15

0 Answers0