C
C
coolfusion2015-04-29 10:37:16
IIS
coolfusion, 2015-04-29 10:37:16

How do Actions work in Controllers when they are accessed by multiple users at once?

So! There is, say, a Home controller and it contains an action named DoSomeThingForUser

class HomeController : Controller 
{
   public ActionResult DoSomeThingForUser(SomeModel model)
   {
      //Что-то делаю с моделью, мб обращаюсь к базе и т.д и возвращаю юзеру 
      return(model)
   }
}

How will this action work when let's say 100 users access it?
The 1st user will fall into this action and he will be locked until he exits from there, respectively, the remaining 99 users will be waiting for him? Or will a separate instance be created for each user ... although this is nonsense, but still?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2015-04-29
@coolfusion

There will be no locks in the action (unless you put them there yourself), and they don't need to be there. The default controller factory creates a controller instance per request, so 99 users won't wait for one. If you need details - search Google for "asp.net mvc controller instancing", a lot of articles fall out from which you can start to understand.

C
coolfusion, 2015-04-29
@coolfusion

Nipheris :

Примерно так kernel.Bind<IDatabaseFactory>().To<DatabaseFactory>().InSingletonScope();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question