unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.45k stars 175 forks source link

How to report progess via api - event-stream #587

Open dos-ise opened 10 months ago

dos-ise commented 10 months ago

Describe the bug I try to report progress for a long running operation. My implementation is based on how i would implment it on ASP.Net Core Unfortunately it does not work. How should I implement something like this for embedio?

**Desktop

       [Route(HttpVerbs.Any, "/import")]
        public async Task ImportPrjAsync([QueryData] NameValueCollection parameters)
        {
            Response.StatusCode = 200;
            Response.ContentType = "text/event-stream";
            Response.ContentLength64 = 10;

            var sw = new StreamWriter(HttpContext.Response.OutputStream);
            for (var i = 0; i < 10; i++)
            {
                await Task.Delay(1000);
                await sw.WriteAsync("1");
                await sw.FlushAsync();
            }
        }