balanv
balanv

Reputation: 10898

is it possible to have a global variable between two WCF services?

Is it possible to have a global variable accessible between two WCF services?

I have written a WCF service to upload an excel file using AJAX uploader. I am trying to read a global variable which I would set in the upload service in another service.

Is this possible or is this approach right?

Upvotes: 0

Views: 287

Answers (2)

StuartLC
StuartLC

Reputation: 107407

Another option may be to use WCF Sessions to track state across multiple consecutive service calls by the same client - on the server, a class instance variable declared would be available to all services methods in the class which are involved in the same session (and would be scoped to just this session).

Note that a global (e.g. static) variable would be shared across all clients, which may not give the the intended behaviour if you have more than one client.

Also, remember to make any thread safety considerations.

Upvotes: 1

Dennis Traub
Dennis Traub

Reputation: 51694

Trying to introduce global variables into an otherwise stateless infrastructure usually isn't recommended.

Upvotes: 2

Related Questions