I have an existing large ASP.NET (ASP.NET Web Forms + MVC support) Application and trying to implement async
programming on project.
For that I created a completely new POC by selecting ASP.NET Application (again ASP.NET Web Forms + MVC support). My POC works great and correctly does async
execution.
Now when I copy exact same code in existing large project, this behaves like synchronous
. I already have latest .NET Framework updates in large application.
Here is my Controller
implementation which is supposed to upload file async
:
[HttpPost]
[ValidateInput(false)]
public async Task<JsonResult> VideoUpload(string Id)
{
for (int i = 0; i < Request.Files.Count; i++)
{
// :::::
await Run(fileStream);
}
return Json(new { error = false, message = "File uploaded." });
}
public async Task Run(Stream fileStream)
{
// :::::
using (fileStream)
{
// A long running method call
await fileUploadRequest.UploadAsync();
}
}
[HttpGet]
public JsonResult GetUploadingStatus()
{
// :::::
return Json(new { statusMessage = statusMessage, totalSent = totalSent, totalSize = totalSize }, JsonRequestBehavior.AllowGet);
}
In above code GetUploadingStatus()
is a GET
method does quick job. This methods receives random (3-4 seconds interval) Ajax
calls and returns uploading status.
When I debug this implementation in large project, I noticed GetUploadingStatus()
returns every results (10-15 Json response) at a time just after fileUploadRequest.UploadAsync()
ends. So I feel this behaves like synchronous
in large project. Then why this works great in a clean project but not in large project?