.net webservice session
Maybe it is obvious but I've seen the question on a forum;
Q:"How to make the session collection work for a .net webservice like for asp.net? "
A:"Just put the following before the web method:"
[ WebMethod(Description="Desc",EnableSession=true)]thats all folks!
hope this helps.
comments are welcome
Ok I've posted this a few time ago. And it still works. But, the session collection is not a real session objectin this case. It is instanciate just before the web method call, but I never seen when it is uninstanciate. For instance the "end_session" event never fire!
Also, I experiment troubles while debuging an object stored in this collection for a web method.
So, use this the least you can and do not expect this to be a good equivalent to the session collection in classical ASP .Net.
Winform, Web Services & credential
Just a tip today.
Last week I built a web service based application which needs a windows authentication.
The schema was:
A winform client
A group of IIS web services.
An oracle database (as alway on this blog lol)
How could the winform client say to the web services. "Hey i'm a member of this windows network, my login is Jdoe, trust me"
Ok, first I asked my favourite web administrator to configure my IIS application to not allow anonymous users. Exactly like for a classical ASPX application.
Then I changed my web.config file, puting the line :
<authentication mode="Windows" />
Ok IIS was then fine to authenticate users.
but my Winform webservice client wasn't ready yet.
In order to be "windowsly" authenticate a webservice client need to send credentials to the server.
The .net framework provide a secure and elegant way to to that:
using System;
using System.Net;
....
MyService.MyWebMethod ws = new MyService.MyWebMethod();
ws.Credentials = CredentialCache.DefaultCredentials;
...
and it works !
I was then able to retrieve informations about my connected users. For instance
the login :
...
strlogin = user.identity.name
...
that's all folks!
hope this helps!
Comments are welcome!
back to work
Hello everybody
I'm back to work! I didn't post these last three weeks because I was
here and also
there ,I also went to
this place .