Click here to Skip to main content
15,040,743 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Import Excel file. After that i wont to redirect to view another view with import data.

Am using one view to import data(Capture View) But i need to display this data Another View (Create view)

What I have tried:

IFormFile file = Request.Form.Files[0];

           string folderName = "UploadExcel";
           string webRootPath = _hostingEnvironment.WebRootPath;
           string newPath = Path.Combine(webRootPath, folderName);
           StringBuilder sb = new StringBuilder();
           if (!Directory.Exists(newPath))
           if (file.Length > 0)
               using var ms = new MemoryStream();

               var Orderz = GetExcelContent(ms);

               model.Neworder = Orderz;

           return View("Create", model);
Updated 14-Dec-20 1:21am

1 solution

To redirect the user to another action once the import has finished, return RedirectToAction:
ControllerBase.RedirectToAction Method (Microsoft.AspNetCore.Mvc) | Microsoft Docs[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900