vendredi 28 février 2020

ASP.NET Core - Maintaining one instance of object for each user on webpage

I'm currently creating a demo webpage in ASP.NET Core for the company I work for. The server maintains a model of a bayesian network that calculates probabilities, given the users input on the client. It is important that the users on the client each have their own network with the probabilities based on their input.

To maintain the network throughout requests, I tried to add the network as a scoped service thinking it would create one instance for each client. I did so by adding services.addScoped<networkClass>(networkClass); in startup and injecting it into my controllers of which the user requests. It didn't work obviously. As I thought about it more, I also realized that I had to somehow know when the user leaves his session so that I can delete the network.

My question is: if I want each web user/client to have their own instance of a, say mathematical network, in ASP.NET Core using MVC and Angular, how would I go about that? And how would I make it last throughout the users session and then notify the server when the user exits the domain so I can delete the network?

Sorry if it is a stupid question, i am fairly new to web development so if you have some documentation on the matter as well that would be appreciated.

Thanks




Aucun commentaire:

Enregistrer un commentaire