ASP.NET Web app not receiving expected cookie from Web service. Wh

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"];
 
G

Guest

I discovered that my C# Windows application only receives the cookie when I
am using the Fiddler HTTP Debugger to monitor HTTP requests. Fiddler creates
an HTTP proxy and imposes itself between an application like Internet
Explorer or my Windows application and the rest of the world.

The Web service I am trying to use is hiding behind a Cisco content services
switch that sends an "arrowpoint" cookie to all new clients and expects the
same cookie with all following requests from the same client.

When a browser or something like Fiddler's HTTP proxy interacts with this
Cisco content services switch, the arrowpoint cookie survives. When my C#
Windows application or my ASP.NET Web application interacts with the switch
directly, the arrowpoint cookie does not survive. Why?

At http://www.xmlwebservices.cc/index_FAQ.htm I found this:
==================
Q: I cannot seem to achieve session maintainance in an XML Web Service from
my Windows Forms application?
A: The client application' proxy uses the HttpClientProtocol classes which
by default do not know about sessions. Therefore you have to enable cookie
management in the client proxy class by adding code like this in your client
application:
myProxyClass.CookieContainer =
new CookieContainer();

It is important to mention that the session is only valid for a single
client proxy instance.
Of course the sample assumes you have configured your Web Service correctly
to maintain session state (see above).
==================

According to the above quote, two things are required: (1) a non-null
CookieContainer for the proxy and (2) the [EnableSession=True] property of
the WebMethod attribute within the Web service.

To me, it seems like I need to do one additional thing to make my Windows
application handle cookies more like Internet Explorer does and like
Fiddler's HTTP proxy does. Would you agree? And if so, what am I missing?
 
G

Guest

http://www.cisco.com/en/US/products/hw/contnetw/ps789/products_tech_note09186a00801c8c2f.shtml

"When a content rule is setup for ArrowPoint cookies, the CSS will wait for
the HTTP GET before injecting the cookie. When the user first visits the
site, the HTTP GET will not contain a cookie. The CSS always checks for the
existence of the ArrowPoint cookie when it receives a client's request. If
this cookie does not exist, the CSS performs server load balancing and
generates a ArrowPoint cookie configured for the choosen server. Since this
is the users first time visiting the site, the CSS will respond by sending
the client back a HTTP refresh page that contains the cookie. The HTTP
metatags in the response will prompt the client's browser to resend the HTTP
GET with the cookie set by the CSS."

I am now thinking that any client that understands and response properly to
HTTP refresh pages will work. Supporting evidence includes my C# Windows
application which doesn't work unless I am also running Fiddler... which
creates an HTTP proxy and places it between the Windows application and the
Internet. Fiddler probably understands HTTP refresh pages just like browsers
do.

Now I am wondering how to change my web service proxy (automatically
generated by Visual Studio by adding a Web reference to the Web service) so
that it understands HTTP refresh requests. Any tips would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top