Skip to content

Commit afc4894

Browse files
committed
83631: Provide support for catch the returned response body in upload
1 parent ce67591 commit afc4894

File tree

1 file changed

+63
-0
lines changed
  • ej2-asp-core-mvc/uploader/EJ2_ASP.MVC

1 file changed

+63
-0
lines changed

ej2-asp-core-mvc/uploader/EJ2_ASP.MVC/async.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,69 @@ public void Save()
167167
}
168168
```
169169

170+
### Server-side configuration for save action with returned response
171+
172+
Here’s how to handle the server-side action for saving the file in server with returned response.
173+
174+
```c#
175+
[AcceptVerbs("Post")]
176+
public ActionResult Save()
177+
{
178+
// for JSON Data
179+
try
180+
{
181+
// Process uploaded data
182+
var responseData = new
183+
{
184+
Success = true,
185+
Message = "Files uploaded successfully",
186+
// Additional data can be added here
187+
};
188+
189+
return Json(responseData);
190+
}
191+
catch (Exception e)
192+
{
193+
var errorResponse = new
194+
{
195+
Success = false,
196+
Message = "File upload failed: " + e.Message
197+
};
198+
199+
return Json(errorResponse);
200+
}
201+
202+
// for String Data
203+
try
204+
{
205+
// Process string data
206+
var data = "success";
207+
// Return the string data
208+
return Content(data);
209+
}
210+
catch (Exception)
211+
{
212+
var data = "failed";
213+
return Content(data);
214+
}
215+
216+
// for File Data
217+
try
218+
{
219+
// Example: Retrieve file path for stream.txt
220+
var filePath = "/stream.txt"; // Example file path
221+
222+
// Return the file
223+
return File(filePath, "text/plain");
224+
}
225+
catch (Exception e)
226+
{
227+
return Content("Failed to retrieve file response: " + e.Message, "text/plain");
228+
}
229+
}
230+
231+
```
232+
170233
## Remove action
171234

172235
The remove action is optional. Specify the URL to handle remove process from server.

0 commit comments

Comments
 (0)