We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

passing additional data with uploader

I am trying to pass additional data to and upload controller for the save process.  There are several examples I've found on the forums including


The examples use:
var valueFromClient = System.Web.HttpContext.Current.Request.Form.AllKeys[0]; 
var ObtainedValue = System.Web.HttpContext.Current.Request.Form[valueFromClient];

However, HttpContext is not available in asp.net core as the examples show.  Is there an example using asp.net core or some other way to handle this?

1 Reply

SP Sureshkumar P Syncfusion Team December 30, 2019 12:59 PM UTC

Hi Patrick, 
Greetings from Syncfusion support. 
We have validated your requirement. we suspect that in HttpContext.Current was removed in ASP.NET Core. We suggest to use HttpContext.Request instead of HttpContext.Current.Request to get rid of your reported issue.  
Kindly refer the below code block. 
    var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "https://localhost:44342/Home/Save", RemoveUrl = "https://localhost:44342/Home/Remove" }; 
@using Syncfusion.EJ2 
    <div class="col-lg-12 control-section" id="target"> 
        <ejs-uploader id="uploadFiles" asyncSettings="@asyncSettings" autoUpload="false" uploading="onFileUpload"></ejs-uploader> 
    function onFileUpload(args) { 
        args.customFormData = [{ 'name': 'Syncfusion INC' }]; 
using Microsoft.AspNetCore.Http; 
using Microsoft.AspNetCore.Http.Features; 
        public IActionResult Save(IFormCollection form) 
            string valueFromClient = Request.Form["name"]; 
            foreach (var file in form) 
                foreach (var file in form) 
                    if (form != null) 
            catch (Exception e) 
                Response.ContentType = "application/json; charset=utf-8"; 
                Response.StatusCode = 204; 
                Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "No Content"; 
                Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message; 
            return Content(""); 
Sureshkumar P 

Live Chat Icon For mobile
Up arrow icon