473,804 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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"];
Feb 1 '06 #1
2 2028
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 HttpClientProto col 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.Co okieContainer =
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=T rue] 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?
Feb 2 '06 #2
http://www.cisco.com/en/US/products/...801c8c2f.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.
Feb 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4722
by: Johnny | last post by:
Searched on google for any info relating to this before posting here but found none. I set up a web service using nusoap on apache php 4.3.8 on windows with error_reporting = E_ALL and had that service set a cookie in the client browser as the first output. Works fine in IE6 and the service returns the state of the cookie in the client browser but in firefox 1.0 the exact same service gives a notice error about an undefined variable...
2
2562
by: BH | last post by:
I developed a small web app using the FormsAuthentication class to set a cookie (FormsAuthentication.SetAuthCookie(value, isPersist)). The cookie persists fine on my local PC when "isPersist" is true and I can see the cookie file in the cookies folder on my disk. However, after I migrated the application to a server, the cookie is no longer written to the disk. It's still in memory and as long as I don't close the browser instance, the...
15
3654
by: Oleg Leikin | last post by:
Hi, (newbie question) I've created some simple .NET ASP application that should store cookies at the client machine. According to the documentation cookie expiration time is set via HttpCookie.Expires property, but property value is the time of day on the client. How can I possibly know client local time ?
1
2002
by: Dean R. Henderson | last post by:
I setup FormsAuthentication on a couple websites where it has been working as expected for a long time. I used this code to setup the same type of authentication on a new website I am working on and the Cookie Name is not getting setup the same way. In my Web.config file, I use the following basic settings on both the old and new websites: <authentication mode="Forms"> <forms name="SiteAuth" loginUrl="Logon.aspx" protection="All"
5
10378
by: LS | last post by:
Can a WebMethod return an Interface type? Can we pass an interface parameter ? Example : public interface IEntity { long Id { get; set; } string Name { get; set; } }
1
2284
by: StevePBurgess | last post by:
I am using a script (see below) to check if cookies are enabled on my website. The script seems to work but I get an Object Expected error. The error repor says it is at the line incidated by the *** below. Any ideas? <script type="text/javascript"> Set_Cookie( 'test', 'none', '', '/', '', '' ); if ( Get_Cookie( 'test' ) )
7
1999
by: =?Utf-8?B?SlA=?= | last post by:
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 public string CreateToken(string User, string App, string County) {
3
8189
by: Dave | last post by:
string m_request = some_web_page; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request ); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Which works fine, but I need to set and send a cookie with the WebRequest. How do I do that?
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.