473,799 Members | 3,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem getting cookie to be recognized by server

rss
SUMMARY:
==========
I am unable to pass along a simple Cookie obtained from a HttpWebRequest
call (Machine A's ASP.NET app) so that another Web Server (Machine B)
recongnizes the cookie.

I have performed the exact steps [I am trying to do programmaticall y] by
entering the URLs into the browser (IE). In this case, everything works.

I have used TcpTrace to monitor the traffic, and have verified that the
Cookie is set in both cases, but the ASP.NET case is doing all POST(s),
whereas the simple URL entering is GET(s). Could this be part of the
problem? I have listed the details below - in case anyone has run into this
type of problem and got it working.

Thanks in advance for any help,
Bob DeRemer
ra*@radicalsoft waresolutions.c om

DETAILS:
========
I have a fairly simple scenario [at least I thought so]. I have a simple,
two machine setup with the following configuration:

MACHINE A [IIS + ASP.NET]
MACHINE B [IIS + ServletExec ISAPI DLL for running our java code]

* both on the same domain
* ASP.NET app (on Machine A) programmaticall y calls a login page against our
own Java ServletExec code (on Machine B) to authenticate - via
HttpWebRequest
* ASP.NET app (on Machine A) takes the cookie from the previous call's
HttpWebResponse and sets the this.Page.Reque st.Cookies collection [in the
hopes that all future page requests will pass along the cookie]
* ASP.NET app (on Machine A) also has an IFrame element whose src attribute
goes to Machine B


Nov 18 '05 #1
3 3602
Hi Rss,

From your description, you have two servers and each one hosts a certain
web application, one is ASP.NET web app and another is java servlet based
web app. Currently, you are trying to use HttpWebRequest to request a login
page in the java web app and then retirve back the authentication cookie
and set into the asp.net web application's cookie colleciton for sequential
use, yes?

As for this problem, here are some of my suggestions:
1. Generally, a cookie item has a Domain attribute which distingish it
between different applications and a path attribute which can distingish
them in the same domain. Also, the ASP.NET, CLASSIC ASP and JSP/Servlet may
have different behavior on manipulating cookie's certain attributes. So the
cookie you retrieved from the jsp/servlet web app may not able to be
directly used in asp.net application (such as store to the asp.net web
app's client and retrieve it back again). We'd better retrieve back the
cookie from jsp/servlet web app and then still use HttpWebRequest and
reattach the cookie and visit the jsp/servlet web app.

2. Also, in asp.net , if we want to store cookie to its client, we have to
use the Response.Cookie s collection rather than the Request.Cookies
collecton. the Request Cookies collectidon is the cookies retrieved from
the clientside but not the ones that will be stored again to client.

Here are some tech articles on cookies in asp.net:
#Basics of Cookies in ASP.NET
http://msdn.microsoft.com/library/de...us/dv_vstechar
t/html/vbtchaspnetcook ies101.asp

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx





Nov 18 '05 #2

Thanks for the reply, and yes - you are exactly right on your summary of
what I am trying to do. I noticed the behavior your are talking about
with respect to Domains, and was trying to set all HttpCookie properties
from the Cookie retrieved from the HttpWebResponse object, but it was no
use. While I could see the Cookie in HTTP header [via TcpTrace], the
Servelet side did not apparently recognize it.

Two interesting NOTEs on behavior:

1) if I ran this such that the ASP.NET application AND the Java servlet
code where running on the same machine, and in the same IIS context
(i.e. same machine and under the same root path) - it works fine!

2) if I run my ASP.NET app that programmaticall y hits the Java Servlet
and grabs the JSESSIONID cookie, then enter the URL to the page on the
Servlet machine that requires the cookie - BUT hit it via the TcpTrace
redirect [which is tunnelling through the ASP.NET machine], it works.
If I enter the direct URL, it does not work - for example:

WORKING EXAMPLE [enter http://aspdotnet:8080/test.irpt and the cookie I
got is recognized in the page] FAILING EXAMPLE [enter
http://servlet_machine/test.irpt and the cookie is NOT recognized UNLESS
I first hit the login page via the same path (i.e.
http://servlet_machine)]

I will gladly try the first suggestion (i.e. HttpWebRequest against the
URL that is being set as the IFRAME src attribute), but I'm not sure how
to handle the result of executing the request. How do I take the
resulting response stream and actually set it in an IFRAME or similar
construct? I need the Iframe because the resulting code has embedded
APPLET tags, etc. - unless there is another way to render this so the
result HTML block is isolated from the rest of the page.

Thanks in advance for you help,
Bob

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
rss
Got the problem solved. It turned out to be a domain problem. I was not
specifying fully-qualified domain names for the two respective machines
(i.e. machineA.domain .com and machineB.domain .com). That made the
difference. After issueing all URL(s) with the fully domain name (i.e.
http://machinea.domain.com/test.irpt), then using just domain.com as the
cookie's domain property, it worked.

Thanks for the suggestions, however, it helped me narrow in on what I
suspected the problem was.

-bob

"microsoft.publ ic.dotnet.frame work.aspnet" <an*******@devd ex.com> wrote in
message news:OW******** ******@TK2MSFTN GP11.phx.gbl...

Thanks for the reply, and yes - you are exactly right on your summary of
what I am trying to do. I noticed the behavior your are talking about
with respect to Domains, and was trying to set all HttpCookie properties
from the Cookie retrieved from the HttpWebResponse object, but it was no
use. While I could see the Cookie in HTTP header [via TcpTrace], the
Servelet side did not apparently recognize it.

Two interesting NOTEs on behavior:

1) if I ran this such that the ASP.NET application AND the Java servlet
code where running on the same machine, and in the same IIS context
(i.e. same machine and under the same root path) - it works fine!

2) if I run my ASP.NET app that programmaticall y hits the Java Servlet
and grabs the JSESSIONID cookie, then enter the URL to the page on the
Servlet machine that requires the cookie - BUT hit it via the TcpTrace
redirect [which is tunnelling through the ASP.NET machine], it works.
If I enter the direct URL, it does not work - for example:

WORKING EXAMPLE [enter http://aspdotnet:8080/test.irpt and the cookie I
got is recognized in the page] FAILING EXAMPLE [enter
http://servlet_machine/test.irpt and the cookie is NOT recognized UNLESS
I first hit the login page via the same path (i.e.
http://servlet_machine)]

I will gladly try the first suggestion (i.e. HttpWebRequest against the
URL that is being set as the IFRAME src attribute), but I'm not sure how
to handle the result of executing the request. How do I take the
resulting response stream and actually set it in an IFRAME or similar
construct? I need the Iframe because the resulting code has embedded
APPLET tags, etc. - unless there is another way to render this so the
result HTML block is isolated from the rest of the page.

Thanks in advance for you help,
Bob

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4

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

Similar topics

1
3228
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value in a variable and make the request again with that cookie as a header value (Digest Authentication). But, the problem we are facing is: That the HttpWebRequest is getting two responses simultaneously, which means that the code should wait after...
7
2148
by: Christoph Pieper | last post by:
Hi, we've the following problem : We have an asp-application which sets the cookie on first login. The cookie will never be touched during user access. The user can work the whole day, but after 6 to 7 hours, the cookie get 2-4 new asp-sessionid's thus overwriting the very first entries in the cookie. Does anyone had the same problem or has a solution. The server is a w2003 enterprise the client has windows xp sp2.
22
3276
by: Kristof Thys | last post by:
Hello, I'm developing a C# - windows forms application. To get some information for my application, I'm connecting to an URL, wich gives me XML generated using php. With 90% of the users, this code just works fine: WebRequest request = WebRequest.Create(URL);
5
3049
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I change the setting in web.config everything seems to work fine as long as I'm using relative paths. The problem is I've got a menuing system that's generated from a site-wide template - so I use a fixed path from the application root - (ie:...
11
3609
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get any requested page to automatically go to the Login.aspx page, AND, the ReturnURL querystring is correct in the address bar, but no matter what, I can't get it, once the user is authenticated, to redirect to the new page. It ALWAYS refreshes the...
1
2803
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value in a variable and make the request again with that cookie as a header value (Digest Authentication). But, the problem we are facing is: That the HttpWebRequest is getting two responses simultaneously, which means that the code should wait after the...
7
2919
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
1
417
by: Steven M. | last post by:
Greetings... I need desperate help with my problem. I guess the solution is related in some way with the cookies getting lost in the authentication process working with some web servers. Appreciate any help you could provide. I've created an application that does the authentication process
4
1785
by: Jay | last post by:
2.0 asp.net app (precomiled in 2005, not updateable, dll's in bin and then merged to one dll)... web app calls a 1.1 (compiled in 2003) webservice initialization webmethod (works). Second call to a different webmethod (does NOT work. The second webmethod uses session state (to re-connect individuals session back together) and crashes... Hypotheses include: can't use precompiled app in 2005 to call 1.1/2003 websevice that uses state....
0
9685
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
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10249
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...
0
10025
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
9068
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...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.