Skip to content

Instantly share code, notes, and snippets.

Created January 31, 2019 01:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
namespace Practical.AspNetCore.SignalR
public class AnnouncementController : Controller
private IHubContext<MessageHub> _hubContext;
public AnnouncementController(IHubContext<MessageHub> hubContext)
_hubContext = hubContext;
public IActionResult Index()
return View();
public async Task<IActionResult> Post([FromForm] string message)
await _hubContext.Clients.All.SendAsync("ReceiveMessage", message);
return RedirectToAction("Index");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment