What is the right way to manage MongoDB connections in ASP.Net MVC?

前端 未结 3 1784
长情又很酷
长情又很酷 2021-02-01 17:01

What is the best practice for managing the MongoServer class life cycle? Should I create one and close it at the end of each request or should it be kept as a singleton for the

3条回答
  •  醉酒成梦
    2021-02-01 17:29

    Inject it using any IOC container (structuremap, Windsor etc.) and keep its lifetime to be on per request basis.

提交回复
热议问题