Scenario: asp mvc application: WebSite. WCF service: Service, with DoSmth() method. I call Service from the WebSite.
What is the proper way to call Service.DoSmth()? I can create it all time I need to use it, like this:
using (var service = new ServiceClient()) {
service.DoSmth();
}
Or I can add Service field to the controller class and create the Service in controller's constructor.
private Service service;
public MyController() {
service = new ServiceClient();
}
I want to know, whats the difference, regarding to sessions, because, if we create the Service in constructor, we create one long session. So what about session time-outs or something like this? And what are the benefits from the other points of views?
Another question is, where to call service.DoSmth()? I've read about mvc pattern, and I think, that the proper way due the pattern is to call it from models, because models should do the work, and controller is only a "manager", but I saw many examples, where people use models only like containers, to pass data from controller to view. So can somebody clarify it for me. .