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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Uploader Response

Thread ID:





143062 Mar 2,2019 11:02 PM UTC Mar 24,2020 11:35 AM UTC ASP.NET Core - EJ 2 4
Tags: File Upload
Edgar Drozdov
Asked On March 2, 2019 11:02 PM UTC

What is 

Response.StatusCode = 204;
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = JsonUtils.Serialize(uploadResult);

I have e.g. net core ApiController 
the way of returning response is Ok(result);
where result contains processed renamed file with additional info.
How I can get this info if in args.response on client side I have only data before uploading and "File Uploaded Successfully

I need my custom serialized object in response instead of predefined response.

Prince Oliver [Syncfusion]
Replied On March 4, 2019 11:26 AM UTC

Hi Edgar, 

Thank you for you contacting Syncfusion support. 

Query 1: What is Reponse.clear(), Response.statusCode and phraseDescription? 

After the server-side actions gets completed, we need to send the response to client side with proper status code and details. By using Response.clear() we have cleared the details from http and have updated the details in the response.  

In our samples, we will not allow to save the files in our server due to security reasons. So, to display the selected files in success state we have return the status code as 204.  

Phrase descriptions are used to send the custom messages from server side to client side. But it will work up to dot net core 2.0 only. Dot net core 2.1 and above versions doesn’t have a reasonPhrase support, we need to send the custom data using headers only. Please refer the below code block. 

Response.Headers.Add("status", "File Already Exists"); 

For further details, kindly refer the below link. 

Query 2: the way of returning response is Ok(result) where result contains processed renamed file with additional info 

You can get the additional data from the server by using the argument “e” in success/failure events. Please refer the below screenshot. 


Please let us know if you need any further assistance on this. 


Naresh Bisht
Replied On March 24, 2020 07:30 AM UTC

Hi sir, I'm also going through this situation can you please send me a project where you have implemented this I'm a beginner in web development thus having a very hard time understanding this a project where it changes the text to "File already exist" when a file with the same name already exist in the database will help me to understand it much better.

Thank you.

Naresh Bisht
Replied On March 24, 2020 10:23 AM UTC

Okay, I got it now all I had to do was add this in my view - 

<ejs-uploader id="UploadFiles" failure="onUplaodFail" asyncSettings="@asyncSettings" uploading="addTokens" multiple="false" autoUpload="false"></ejs-uploader>


    function addTokens(args) {
        args.currentRequest.setRequestHeader('XSRF-TOKEN', document.getElementsByName('__RequestVerificationToken')[0].value);

    function onUplaodFail(args) {
    var header = args.response.headers;
    var statusMessage = header.slice(header.indexOf('status'), header.indexOf('x-powered-by'));
    statusMessage = statusMessage.slice(statusMessage.indexOf(',') + 1);
    args.statusText = statusMessage;


and in my controller - 
                            Response.StatusCode = 404;
                            Response.Headers.Add("status", "File Already Exists");

The above code works for ASP.NET core 3.1 in case anyone faces the same issue

Sureshkumar P [Syncfusion]
Replied On March 24, 2020 11:35 AM UTC

Hi Naresh, 
Thanks for your update. Please get back to us if you need any further assistance on this. 
Sureshkumar P 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon