|
CookieContainer from request object suppose to hold all the cookies from response, besides I checked the response object in run time and the cookies is empty too.
|
|
|
|
|
atj885 wrote: CookieContainer from request object suppose to hold all the cookies from response
Why do you think that?
From MSDN Library:
"CookieContainer is a null reference (Nothing in Visual Basic) by default. You must assign a CookieContainer object to the property to have cookies returned in the Cookies property of the HttpWebResponse returned by the GetResponse method."
atj885 wrote: I checked the response object in run time and the cookies is empty too.
Then the site didn't set any cookies. Try another site, now that you know where to look for the cookies.
---
single minded; short sighted; long gone;
|
|
|
|
|
Stop quoting facts at people. It only confuses them.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Don't you see I assign a New object to cookie container on the second line?
request.CookieContainer = new CookieContainer();
Both Yahoo and Amazon send cookies back for sure, if you don't know the subject, please don't comment and waste both of our time. Besides this is the exact code from microsoft site, any one have experience?
|
|
|
|
|
atj885 wrote: Don't you see I assign a New object to cookie container on the second line?
request.CookieContainer = new CookieContainer();
Yes, I see that. You put the CookieContainer in the request object. The cookies that the server sets are returned in the response object. I have already told you this twice.
atj885 wrote: if you don't know the subject, please don't comment and waste both of our time.
I know the subject, but I really feel that I am wasting my time. It's like talking to a wall. A very ungrateful wall.
atj885 wrote: Besides this is the exact code from microsoft site
Where? If it really is, then they have really screwed up.
Here is the page in MSDN Library where you can find the text that I quoted earlier:
MSDN Library: CookieContainer property[^]
Take a look at the example code on the page. Notice how they read the cookie values from the response object, not the request object.
---
single minded; short sighted; long gone;
|
|
|
|
|
Here is the code from MSDN libarary form your link:
if (args == null || args.Length != 1)
{
Console.WriteLine("Specify the URL to receive the request.");
Environment.Exit(1);
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(args[0]);
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
//response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
// Print the properties of each cookie.
foreach (Cookie cook in response.Cookies)
{
....
}
Here is my code:
string L_URL = "http://www.amazon.com"
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(L_URL);
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
//response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
//This always return 0
MessageBox.show(response.Cookies.count.ToString());
Tell me what's the difference? The line I commented out does not make any difference.
Can you copy this code to a simple window project and try yourself, and tell me you got
the cookies count > 0? no matter from the request or response object, it is always 0. You may change the URL to any site, Amazon.com is the one I am 100% sure they return cookies.
|
|
|
|
|
Now you are getting the cookies from the response object, which is correct.
I copied your code, made the neccesary corrections to make it compile, and ran it. Amazon returns one cookie.
---
single minded; short sighted; long gone;
|
|
|
|
|
I'll 5 you for solving the problem of the ungrateful little troll.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
I'm trying to create a custom Wizard that generate C# project.
Can I use the C++ custom project? Or is there other way to do it in C#?
Any information may be helpful
Thanks
|
|
|
|
|
Check out this[^]. There is a link to a VS2005 version in the comments.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi,
I am using CD_ripper where cd insertion removal events fires successfully on
Win XP and Win2K but it is not working on vista. Please can any one guide me.
Thanks
Sumedh
|
|
|
|
|
hi , im working on a script writing program which highlights certain words in the text.
i use the RichTextBox control and it's property selectioncolor in order to apply a color to the text. the problem is that the selection of the text changes the value of the scroll bars and it causes the scroll bar to jump. so my question is : how can i get/set the value of the scroll bar of the richtextbox control?
or if someone has a alternative solution for my problem.
sorry for any english mistakes.
:P
|
|
|
|
|
Hi all,
I tried to write a mail queuer with C#.
At the Mail Sending step, I am using smtpClient.Send(mailMessage) call.
The call is not throwing exception.
The application is made to wait by a Console.Read() call after sending all the mails in a loop. [I have tried with 10, 100, 2500 mails at different shots]
But 100% of the mails I have sent do not reach my mailbox when the application waits at the Console.Read().
However, as soon as I hit enter, all the pending mails are sent.
But I need this app to run on a webserver. While testing the same code as WebService, I had to restart the server [ASP.NET Development Server] to send those pending mails.
Now I am at a fix, because my smtpClient.Send() methods are fired nicely without any exception, but probably the mails are queued at some other end, which I don't know how to flush.
Please help.
Thanks in advance.
Deb
|
|
|
|
|
Try using the async version of the Read method. And you should also treat the SendCompleted event. It's better using the async version because your application doesn't hang while the mails are being sent.
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Hi,
Thanks for the reply.
"Try using the async version of the Read method." -- I hope you meant SendAsync method.
I have already tried with the SendAsync method, and handled the callback.
But it was of no help. So I have implemented another part of the application with asynchronous delegate invoke, to release the caller/client instantly, while the Send operation part is synchronous.
I think either the Framework, or the OS is maintaining a buffer somewhere, which is getting flushed when the process terminates. However this is what I think, and I can't solve this problem right now.
Thanks,
Deb
|
|
|
|
|
I wrote a Windows Service to send email. My applications put the necessary information in a database table, the emailer reads the table and sends the emails.
|
|
|
|
|
Yes, obviously writing a windows service is possible, but I need it as a WebService.
However, I can use other approaches as well, but I need to send all the mails.
As also, due to certain constraints, I can't use database, or even flat files for mail sending. I am using a derived Queue<t> with an overloaded EnQueue method, which fires a delegate whenever any item is added to the queue.
My problem is that, even if the smtpClient.Send call is executed successfully, all the mails are not sent until the running thread/process is killed.
I can't understand the cause of the problem.
Say I fired Send method 100 times. I am getting no exceptions, and all 100 calls are going through fine. But all 100 mails are not sent until I close the process from which Send method is fired.
It will be very helpful, if I atleast get an explanation why this is happening, if not how to solve this.
Thanks.
Deb
|
|
|
|
|
does your app terminate after the Console.Read() ? If so you're right about it being a buffer issue. Check the smtpClient class for a Flush method. IF for some reason there isn't one the Close or Dispose methods will do the same thing as shutting down the app. Just remember you'll need to reallocate a new smtpClient the next time you need to send.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Yes, the app terminates after the Console.Read().
I am still in problem as SmtpClient class has no flush method.
And I cannot Dispose off any client, as there is an implementation of client pooling. So I am creating the clients with identical credentials, and Host settings, and maintaining a queue of specified number of clients.
I am thinking of recreating the client list after some idle time, but I am not sure.
But is it really some buffer issue at the SmtpClient end, or at some other end?
Because if it is at some other end, I am not sure whether disposing off the clients will flush it. And where is the buffer?
Deb
|
|
|
|
|
|
hi guys,
i am stuck with this problem for last 2 days,
i have set the timeout property to 60 , still it does not send emails untilli uninstall the service.
please help!happy coding!
|
|
|
|
|
Hello,
I have a lame question about passing a string variable from one aspx.cs file to another aspx.cs file.
In the first page I am retrieving the current server address as so:
psServerAddress = Request.ServerVariables["Server_Name"];
psServerAddress is declared in the second aspx.cs file.
Goal: I want get() and set() methods to retrieve the current server name and then access it in
my second aspx.cs file.
I don't want to use GetQueryString
|
|
|
|
|
You could try posting this question on the ASP.NET forum, but I might give you an idea. You can create two methods Get, Set. In the page you want to call them you have to reference the page that contains those methods to gain access to them. To reference a page you can use the <%@ Reference page="..." />. For more details see this
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
I need to pass the server name because the user control in reference is built in a separate project. The dll is built into the project I am currently working in. The problem is, at the time the user control is instantiated, we are screen scraping from an insurance carriers site. I know it sounds confusing, but trust me, at this time I cannot do the request.server... to retrieve the current server from where we originated.
|
|
|
|
|