• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 805
  • Last Modified:

WCF on ASP.NET

Is it possible to create a single WCF client connection for each web user? If so, where do I create the WCF client object?

Note: Not a new WCF connection for each page.

P.S. Newbie on ASP.NET
0
Thomasian
Asked:
Thomasian
  • 2
  • 2
2 Solutions
 
käµfm³d 👽Commented:
I'm afraid your requirment isn't clear. Can you describe the environment in a bit more detail? What do you mean by "each web user" with respect to a WCF application?
0
 
ThomasianAuthor Commented:
I already have a WCF server app which manages the business rules, users and roles.

Now, I am going to create a web application which connects to the WCF server. The web server will have 3 pages.  A log-in page, a change password page, and the main page.

The main page will have 2 gridviews to show statistical data and a few buttons which simply sends a command to the WCF server.

Now, the first thing a user has to do is to log in on the Log-in page. I then have to create a connection to the WCF server to authenticate the data entered by the user. When authenticated, it will then be redirected to show the main page which shows some statistical data and some buttons.

The statistical data will be updated regularly so I am thinking of a WCF callback when the data is updated. If not possible, maybe a timer to regularly check for updates.

Now, can I create a single WCF connection throught the "session?" so that I won't have to connect/disconnect for every update/page request.
0
 
Vel EousResearch & Development ManagerCommented:
You service implementation can be decorated with a ServiceBehavior attribute of which one of its properties is the InstanceContextMode.  This property expects one of three InstanceContextMode enumerations;

PerSession (default mode)
PerCall
Single

The PerSession InstanceContextMode creates a new InstanceContext object for each session.  If for example you had five concurrent users, each user would interact with a unique instance of your service.  Conversely the Single InstanceContextMode uses a single InstanceContext object for all sessions.

From what you have mentioned, the default InstanceContextMode should provide the functionality you desire.  Have you implemented any of what you have mentioned above and if so, what is working and what is not working for you?

References:
http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.instancecontextmode.aspx
http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx
0
 
ThomasianAuthor Commented:
Where do I create the WCF connection? On Global.asax?

Is it possible to initiate callback to the client for update notification?
0
 
Vel EousResearch & Development ManagerCommented:
Where do I create the WCF connection? On Global.asax
I would create the connection only when needed, which I assume is on your main page.

Is it possible to initiate callback to the client for update notification?
It is possible, however, only netTcpBinding , namedPipeBinding and wsDualHttpBinding support callbacks due to the connectionless nature of HTTP.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now