Hello All,
In my WPF app I would normally create a global variable at the top of a class to hold data that is coming in on my websocket.
What should I do for a .Net Core Application? Web Application.
I would like to store all my data in a object that I can access it throughout my controller.
Currently when I try this the object gets set to null each time I call it.
What is the best way to do something like this? I was looking at a memorycache I think it was called. Maybe something like that or what are my options?
public class HomeController : Controller
{
public List<SocketResult> lstTrades { get; set; } = new List<SocketResult>();
public HomeController(ILogger<HomeController> logger, IHttpClientFactory httpClient, IHttpContextAccessor httpContextAccessor, IMarketFeed marketFeed, IBinanceSocketClient binanceSocketClient)
{
_logger = logger;
_httpClient = httpClient;
_httpContext = httpContextAccessor;
_marketFeed = marketFeed;
_binanceSocketClient = binanceSocketClient;
}
[HttpPost]
public async Task<IActionResult> AddDataToMemory(string model)
{
if (model != null)
{
lstTrades.Add(new SocketResult() {Price = model.p });
}
return NoContent();
}
}