G
Guest
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"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
(2) When the page loads, I make sure that the proxy for the Web service has
a non-null CookieContainer:
proxy = new PartnerWebServiceProxy();
proxy.CookieContainer = 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["CookieContainer"] == null)
Session["CookieContainer"] = proxy.CookieContainer;
else
proxy.CookieContainer = (CookieContainer)Session["CookieContainer"];
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"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
(2) When the page loads, I make sure that the proxy for the Web service has
a non-null CookieContainer:
proxy = new PartnerWebServiceProxy();
proxy.CookieContainer = 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["CookieContainer"] == null)
Session["CookieContainer"] = proxy.CookieContainer;
else
proxy.CookieContainer = (CookieContainer)Session["CookieContainer"];