I have two versions of the same program that send requests to a Web service.
One version is a Windows application written in C#, and it properly handles
a cookie created by the Web service. All I had to do was make sure that the
proxy for the Web service had an initialized CookieContainer .
The second version is an ASP.NET Web application, and it never receives the
expected cookie from the Web service. I can tell because a breakpoint
immediately after a request shows that the CookieContainer for the proxy
holds zero cookies. A breakpoint in the other program shows one cookie.
I have done three things in an attempt to prevent the cookie from getting
dropped somewhere. I feel like I am missing something... What should I do
differently?
(1) The web.config file for my ASP.NET Web application contains the following:
<sessionState
mode="InProc"
stateConnection String="tcpip=1 27.0.0.1:42424"
sqlConnectionSt ring="data source=127.0.0. 1;Trusted_Conne ction=yes"
cookieless="fal se"
timeout="20"
/>
(2) When the page loads, I make sure that the proxy for the Web service has
a non-null CookieContainer :
proxy = new PartnerWebServi ceProxy();
proxy.CookieCon tainer = new CookieContainer ();
(3) I also make sure that the Session object and the proxy for the Web
service are holding on to the same CookieContainer :
if (Session["CookieContaine r"] == null)
Session["CookieContaine r"] = proxy.CookieCon tainer;
else
proxy.CookieCon tainer = (CookieContaine r)Session["CookieContaine r"];