public async Task <ActionResult> OnPost() { var rptFileUpload = Path.GetTempPath() + Guid.NewGuid().ToString() + ".txt"; var tempFile = Path.GetTempPath() + Guid.NewGuid().ToString() + ".txt"; using (var fileStream = new FileStream(rptFileUpload, FileMode.Create)) { await Upload.CopyToAsync(fileStream); } ProcessFile.Process(rptFileUpload, tempFile, _hostingEnvironment.ContentRootPath + "\\Data"); return(new RedirectToPageResult("Index")); }