0

I don't know if it possible but I would like to display an alert box when an async method is finish even if we change view on the website.

For exemple : I'm on page "A" and I run an async method on my controller "A" with this code :

public async Task<ActionResult> functionA()
{

  Task task = new Task(() =>
    {
        LotofAction();
        System.Threading.Thread.Sleep(5000);
    }
  );

  task.Start();
  await task;
  return RedirectToAction("Index", "Home");
}

If I change page to Page "B" before end of task, my controller will not redirect to Home/index (in debug I can go to the line but no redirect)

If I do not change page I will redirect to the correct page

So I have two questions : How to to execute an alert box (in javascript) instead of redirect to action ? How my controller can display this alert even if we change of page ? (I do not find any "master" controller on MVC)

skerdreux
  • 25
  • 4
  • You could definitely achieve this functionality using SignalR. It may also be possible using HTML5 server-sent events, but I'm not so familiar with those. – John M May 09 '17 at 14:39
  • See this http://stackoverflow.com/a/23591388/4868839 – User3250 May 09 '17 at 15:41

0 Answers0