I have a long running process that is called via a Nancy Module Get method. Rather than have the browser hang while the process runs I would like this call to be asynchronou
I am new to the async / await features of C#5 but I feel sure these are meant for just this kind of task.
No. async
/await
are intended to make asynchronous programming easy within the context of a single process. They do not change the nature of HTTP communications.
When you use await
on an ASP.NET server (in the context of an HTTP request), you are returning the ASP.NET thread to the thread pool. However, ASP.NET is aware that the HTTP request has not completed, so it does not complete the response to the client (browser).
This is by design.
You'll need to use AJAX, SignalR, or some other solution in order to do what you want.
try setting the page attribute Async="true"
in the aspx page
after doing that it wold look like this
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="XXX.aspx.cs" Inherits="xxx" Async="true" %>
the in tcode behile file you can make the tasks and methods of type async and calll await
tasks from them ...
it might work