Re: Storing Cookies from C#.NET Application
- From: Laurent Bugnion <galasoft-lb@xxxxxxxxxx>
- Date: Tue, 24 Oct 2006 14:24:54 +0200
Hi,
Jono wrote:
Hi Laurent,
Thanks for your post but unless I misunderstood your blog, I am
approaching the problem from a different perspective. I have no access
to the web service code that runs on the server; all I have to do is
store all the cookies sent by the server and return them on subsequent
requests if they are valid (e.g. they match the server's domain and
path and the cookies haven't expired.) I am thinking of using the
CookieContainer object and serializing it to XML on the file system in
between runs of the client application so that cookies don't expire
prematurely (e.g. a cookie might be set to expire only at the end of
the week but the client application might restart many times before
that).
Regards,
Jono
No, no, this code runs on the client:
public partial class Page1 : Page
{
private GetSessionIdService.Service1 m_oService
= new GetSessionIdService.Service1();
public Page1()
{
InitializeComponent();
m_oService.CookieContainer = new System.Net.CookieContainer();
}
}
You see the instantiation of the web service in my WPF application in your case, it would be in the WinForms "OnInit" method, probably), and then you must create and set the "CookieContainer" property of the web service client.
If no CookieContainer is created, the session cookie sent by the web service will be ignored, and a new session will be started on every call.
HTH.
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
.
- References:
- Storing Cookies from C#.NET Application
- From: Jono
- Re: Storing Cookies from C#.NET Application
- From: Laurent Bugnion
- Re: Storing Cookies from C#.NET Application
- From: Jono
- Storing Cookies from C#.NET Application
- Prev by Date: Re: Peristent Data - Registry, Settings
- Next by Date: C # installation
- Previous by thread: Re: Storing Cookies from C#.NET Application
- Next by thread: Adding line breaks in label
- Index(es):
Relevant Pages
|