This is a design advice question more than a coding question. I have an application where the user needs to login and only after logging in, the user is allowed to upload data to the server. With PHP and sessions, it was very easy to store the logged in username in a session and then work everything from there.
With WCF, the only thing I can think of is storing the username and password locally when the user logs in and change the function to upload data from:
UploadData(string data);
to:
UploadData(string data, string username, string hashedPassword)
So the credentials are sent every time the data is sent. Is there a better implementation?
I’ve had a look at this, but it seems overly complicated:
http://hyperthink.net/blog/a-simple-ish-approach-to-custom-context-in-wcf/
Note that I need to be able to identify each user that calls UploadData individually.
If the server you are calling is stateless then making an initial call to validate the user and from then on sending the credentials or some sort of session key in each method call does make the most sense.