Here is how my system is set up:
- A web service using ASP.Net web service
- The web service has a web method with EnableSession=true
- A client which refers to the web service using "Service References" (note: not "Web References")
- The app.config of the client has allowCookies=true
On the client side, I have the following code to upload a file to the service
bool res = service.InitiateUpload();
if (res) {
do {
read = stream.Read(buffer, 0, BLOCK_SIZE);
if (read == BLOCK_SIZE)
res = res && service.AppendUpload(buffer);
else if (read > 0)
// other call to AppendUpload, after buffer manipulation
On the server side, I have code that checks if the session id from the call to InitiateUpload is the same as AppendUpload.
[WebMethod(EnableSession=true)]
public bool InitiateUpload() {
lock (theLock) {
if (IsImportGoingOn)
return false;
theImportDataState = new ImportDataState(Session.SessionID);
}
return true;
}
[WebMethod(EnableSession=true)]
public bool AppendUpload(byte[] data) {
lock (theLock) {
if (!IsImportGoingOn)
return false;
if (theImportDataState.session != Session.SessionID)
return false;
theImportDataState.buffer.AddRange(data);
return true;
}
}
The call to AppendUpload returns false, because of the mismatching session ids. Why is that? As far as I can see, I have the right attributes for the web method, the client has the correct config, and the same instance of the proxy is used. Am I missing something?