Hi JP,
Quote:
HttpContext.Current.Response.Cookies.Add(myCookie) ; //doesnt work
What do you mean it doesn't work? Do you get an error, or you're just not
seeing the Cookie on the successive request for the next the Web Service
method? If the latter, you ned to set up your WS Proxy on the client to
handle cookies. We enventually settled on using SOAP header, rather than a
cookie, so I don't have live code to demonstrate this, but if I recall
correctly, you need to code something like
m_WSProxyClass.CookieContainer = new System.Net.CookieContainer();
So that your proxy will now have access to cookies for the purpose of
receiving and sending.
If this doesn't do it for you, I will see if I can dig up some old code from
when we were using cookies. We did manage to get it to work and so should
you.
Standard caveat applies: If your Web Services are going to rely on coookies,
you will be limited to HTTP clients. Other clients which don't support the
cookie mechanism won't be able to use your services.
Hope this helps,
Joseph Geretz
"JP" <JP@discussions.microsoft.comwrote in message
news:7713F4F9-7A6C-43F9-BA6D-39981234BABE@microsoft.com...
Quote:
>I need to design a WS that will after authenicating the user, create a
>cookie
on the users PC that made the request. All the code I keep finding is how
to
get a WS to read a cookie, I need it to create one. The below code doesnt
add
the cookie to my cache. However if I place this in an non asmx page its
fine
>
Any help you offer is apperiated
>
[WebMethod(EnableSession=true)]
public string CreateToken(string User, string App, string County)
{
//Do some stuff
...
...
>
HttpCookie myCookie = new HttpCookie("NameMaster");
myCookie.Domain = "mydomain.com";
myCookie["ID"] = Result.ToString();
myCookie["User"] = User;
myCookie["App"] = App;
myCookie["County"] = County;
myCookie.Expires = DateTime.Now.AddMinutes(30);
HttpContext.Current.Response.Cookies.Add(myCookie) ; //doesnt work
--
JP
.NET Software Developer