Hi,
I'm trying to use the following code:
HttpWebRequest webRequest = WebRequest.Crea te(LOGIN_URL) as HttpWebRequest;
webRequest.Cook ieContainer = new CookieContainer ();
HttpWebResponse webResponse = (HttpWebRespons e) webRequest.GetR esponse();
This code let me get the cookie (cookie PHPSESSID) I need, from
webResponse.
I will need this cookie to get the page that i really need.
Now I will copy the cookie to the HttpWebRequest that i will use to get the
real needed page:
HttpWebRequest httpWebRequestL ogin =
HttpWebRequest. Create(LOGIN_UR L_LOGIN) as HttpWebRequest;
httpWebRequestL ogin.CookieCont ainer = new CookieContainer ();
//note: webResponse.Coo kies[0] have the PHPSESSID cookie (i know this)
httpWebRequestL ogin.CookieCont ainer.Add(webRe sponse.Cookies[0]);
httpWebRequestL ogin.Method="PO ST";
httpWebRequestL ogin.ContentTyp e="applicatio n/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter
(httpWebRequest Login.GetReques tStream());
requestWriter.W rite(data);
requestWriter.C lose();
//lets try to get the page
HttpWebResponse httpWebResponse Login =
(HttpWebRespons e) httpWebRequestL ogin.GetRespons e();
The page didn't come out! Because the cookie PHPSESSID wasn't on the
httpWebRequestL ogin, I think!
So what in the name of LORD am I doing wrong (in the process of copying the
cookie from the webResponse to the httWebRequestLo gin)?
Please help me...
Thanks on advance,
o.f 4 2291
Why are you creating a new cookiecontainer for the next request? You should
just reuse the first cookiecontainer that you created, and it should just
work fine. WebRequest will send the cookie in that container to the new
server, after making sure that the domains etc match.
--
feroze
-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.
See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------
"octavio.filipe " <02********@net cabo.pt> wrote in message
news:Xn******** *************** **********@207. 46.248.16... Hi,
I'm trying to use the following code:
HttpWebRequest webRequest = WebRequest.Crea te(LOGIN_URL) as HttpWebRequest; webRequest.Cook ieContainer = new CookieContainer ();
HttpWebResponse webResponse = (HttpWebRespons e) webRequest.GetR esponse();
This code let me get the cookie (cookie PHPSESSID) I need, from webResponse. I will need this cookie to get the page that i really need. Now I will copy the cookie to the HttpWebRequest that i will use to get the real needed page:
HttpWebRequest httpWebRequestL ogin = HttpWebRequest. Create(LOGIN_UR L_LOGIN) as HttpWebRequest; httpWebRequestL ogin.CookieCont ainer = new CookieContainer (); //note: webResponse.Coo kies[0] have the PHPSESSID cookie (i know this) httpWebRequestL ogin.CookieCont ainer.Add(webRe sponse.Cookies[0]); httpWebRequestL ogin.Method="PO ST"; httpWebRequestL ogin.ContentTyp e="applicatio n/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter (httpWebRequest Login.GetReques tStream()); requestWriter.W rite(data); requestWriter.C lose();
//lets try to get the page HttpWebResponse httpWebResponse Login = (HttpWebRespons e) httpWebRequestL ogin.GetRespons e();
The page didn't come out! Because the cookie PHPSESSID wasn't on the httpWebRequestL ogin, I think! So what in the name of LORD am I doing wrong (in the process of copying the cookie from the webResponse to the httWebRequestLo gin)?
Please help me... Thanks on advance, o.f
Why are you creating a new cookiecontainer for the next request? You should
just reuse the first cookiecontainer that you created, and it should just
work fine. WebRequest will send the cookie in that container to the new
server, after making sure that the domains etc match.
--
feroze
-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.
See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------
"octavio.filipe " <02********@net cabo.pt> wrote in message
news:Xn******** *************** **********@207. 46.248.16... Hi,
I'm trying to use the following code:
HttpWebRequest webRequest = WebRequest.Crea te(LOGIN_URL) as HttpWebRequest; webRequest.Cook ieContainer = new CookieContainer ();
HttpWebResponse webResponse = (HttpWebRespons e) webRequest.GetR esponse();
This code let me get the cookie (cookie PHPSESSID) I need, from webResponse. I will need this cookie to get the page that i really need. Now I will copy the cookie to the HttpWebRequest that i will use to get the real needed page:
HttpWebRequest httpWebRequestL ogin = HttpWebRequest. Create(LOGIN_UR L_LOGIN) as HttpWebRequest; httpWebRequestL ogin.CookieCont ainer = new CookieContainer (); //note: webResponse.Coo kies[0] have the PHPSESSID cookie (i know this) httpWebRequestL ogin.CookieCont ainer.Add(webRe sponse.Cookies[0]); httpWebRequestL ogin.Method="PO ST"; httpWebRequestL ogin.ContentTyp e="applicatio n/x-www-form-urlencoded";
StreamWriter requestWriter = new StreamWriter (httpWebRequest Login.GetReques tStream()); requestWriter.W rite(data); requestWriter.C lose();
//lets try to get the page HttpWebResponse httpWebResponse Login = (HttpWebRespons e) httpWebRequestL ogin.GetRespons e();
The page didn't come out! Because the cookie PHPSESSID wasn't on the httpWebRequestL ogin, I think! So what in the name of LORD am I doing wrong (in the process of copying the cookie from the webResponse to the httWebRequestLo gin)?
Please help me... Thanks on advance, o.f
What you are saying is that I should do something like this:
CookieContainer cc = webRequest.Cook ieContainer;
httpWebRequestL ogin.CookieCont ainer = cc;
or should I use this:
CookieContainer cc = new CookieContainer ();
cc.add(webRespo nse.Cookies[0]);
My doubt is: should i copy the CookieContainer from the WebRequest, or
should I create a CookieContainer and add the Cookie that i whant from
webResponse?
This doubt exists because if I debug the response I can see the cookie
i whant to copy, but if i debug the request i can't see the cookie i
want anywhere!
Thanks
o.f
On Thu, 19 May 2005 15:56:15 -0700, "Feroze [msft]"
<fe*****@online .microsoft.com> wrote: Why are you creating a new cookiecontainer for the next request? You should just reuse the first cookiecontainer that you created, and it should just work fine. WebRequest will send the cookie in that container to the new server, after making sure that the domains etc match.
You shoud use the first option:
CookieContainer cc = new CookieContainer ();
httpWebRequest. CookieContainer = cc;
and make sure you use the same cookiecontainer for all webrequest's
--
feroze
-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.
See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------
"o.f" <02********@net cabo.pt> wrote in message
news:rt******** *************** *********@4ax.c om... What you are saying is that I should do something like this:
CookieContainer cc = webRequest.Cook ieContainer; httpWebRequestL ogin.CookieCont ainer = cc;
or should I use this:
CookieContainer cc = new CookieContainer (); cc.add(webRespo nse.Cookies[0]);
My doubt is: should i copy the CookieContainer from the WebRequest, or should I create a CookieContainer and add the Cookie that i whant from webResponse? This doubt exists because if I debug the response I can see the cookie i whant to copy, but if i debug the request i can't see the cookie i want anywhere!
Thanks o.f
On Thu, 19 May 2005 15:56:15 -0700, "Feroze [msft]" <fe*****@online .microsoft.com> wrote:
Why are you creating a new cookiecontainer for the next request? You should just reuse the first cookiecontainer that you created, and it should just work fine. WebRequest will send the cookie in that container to the new server, after making sure that the domains etc match. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stijn Goris |
last post by:
hi all,
Trying to get those cookies to work but they wont...
Doing this. Have a page login.php wich tests the user and pass. If they are
correct a cookie is set with one variable like this: setcookie
("cookieUser", $user);
then the browser is sent with header("Location: spelersPage.php"); to
another page.
I there try to read the cookievariable cookieUser on the spelersPage.php
|
by: Paul |
last post by:
I link to a web site from an Excel spreadsheet. The page i link to is
getCookie.asp which sets a cookie then returns back some html which opens a
new window, to the same site but a different page (same folder).
The cookie is not received. Can someone explain why?
I worked around this by adding a cache-control header with a value of
no-cache. This fixes the problem. Unfortunately that causes another
problem with Internet Explorer...
|
by: Syed Ghayas |
last post by:
Hi,
I've been having problem writing a cookie. Everything goes ok but when I
supply the .Path property to "/" It just write the cookie when there is no
cookie present, but when I try to update the cookie (or overwrite the cookie)
it doesnt change it.
My requirement to supply the path to "/" because ASP.NET reads it. If I
write the cookie without supplying the path, the ASP.NET pages are unable to
read the cookie.
|
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.
|
by: marshalli |
last post by:
Hi:
I have a problem with writing cookie from Jacascript.
My problem is that I have two server,
one is A, and the other is B.
(1) I call a aaa.html from A.
In aaa.html :
...
<iframe id="frame1" src='http://B/bbb.html'></iframe>
...
(2) In bbb.html :
| |
by: Michal A. Valasek |
last post by:
Hello,
I have problem deleting cookies and cookies values (using framework version
1.1 on W2003).
When I try to remove entire cookie, by calling
Response.Cookies.Remove("Test"), nothing happens, the cookie "Test" remains
unchanged.
When I try to remove one of cookie values, by calling
|
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...
|
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...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |