.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Local Cookies Storage, HttpWebRequest and HttpWebResponse

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :.NET Framework
How to work with it? How way to place cookies retrieved from HttpWebResponse to the local Cookies storage? Please show me example

View Complete Post

More Related Resource Links

Https HttpWebResponse/HttpWebRequest Error


I have implemented a https HttpWebResponse in .Net 3.5 as follow.

            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("https://someDomain.com");
            System.Net.ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidation;

            request.Credentials = System.Net.CredentialCache.DefaultCredentials;
            System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
            System.IO.Stream responseStream = response.GetResponseStream();
            System.IO.StreamReader reader = new System.IO.StreamReader(responseStream);
            string responseData = reader.ReadToEnd();

        public bool RemoteCertificateValidation(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            return true;


Now the problem is when ever it wants to read from the created URL (request.GetResponse();
) it throws the following exception:

"The underlying connection was closed: An unexpected error occurred on a receive."

I have searched and found out there are some method in .Net 1.1 which you have to download certificate and add a reference to that. Also have to implement the ICertificatePolic

HttpWebResponse cookies with no path


Hello All,

I am developing an application which requires a logon to a website.

I am using Firefox and Tamper to view the HTTP traffic and trying to replicate this using HTTPWebRequest/Response objects. 

According to Tamper, multiple cookies are returned by the response object: the Set-Cookie header reads:

Set-Cookie=JSESSIONID=X1X1; Path=/; Secure vb_session_key=96160; Expires=Sun, 30-Oct-2011 02:09:21 GMT
abc123=""; Expires=Sun, 30-Oct-2011 02:09:21 GMT
SessionLoginUser=chans; Secure
WLSessionKeyHashCode=-250316961; Secure

When I try to parse the "Set-Cookie" header, I am able to read only the JSESSIONID value, which I think is down to the fact that the Path has been specified. I also tried using the CookieContainer, but I encountered the same problem.

Any ideas on how to view all cookies ?

Thx in advance

HttpWebRequest and HttpWebResponse


Hi, I use the HttpWebRequest to download a .pdf file from an http URL, but my problem is that the pdf file is generated when the URL is invoked, and between invocation and generation of the file, an html wait page is generated. For this my HttpWebResponse get the html wait page. My question is how can I get the pdf file and ignore the html page wait?
Thank you in advance

Building a 3-Tier App with Silverlight 3, .NET RIA Services, and Azure Table Storage

Silverlight 3, .NET RIA Services, and Windows Azure Services Platform makes a 3-tier Cloud application easier to build: Silverlight 3 as presentation tier, .NET RIA services as the business logic and data access tier, and Windows Azure Table as the data storage tier. The sample application in this article demonstrates the architecture with a simple Survey application with all these technologies working together from Windows Azure.

Local variable scoping in C#

In my previous post, Compiler-generated scopes for local variable declarations, I briefly touched on the issue of multiple meanings applied to the same name. In this post, I'll aim to flush out the compiler's rules with regards to binding names in their local scopes.

Compiler-generated scopes for local variable declarations

I was tasked with understanding and fixing a bug on error reporting with foreach iteration variables the other day, and it got me thinking about local variable scoping rules in C# in general. First, the bug.


Keen Explanation About Cookies

Cookies and Helpers


The api guide is real briefe about cookies. I would I go about creating/assiging a cookie, setting exporation, and anything else...

Could someone just list out the helper capabilities?

Thanks for your time...!

How to authenticate local user usin ldap or non domain authentication



I created one application, and I need to authenticate local user. This user is the user who is login to his/her Personal Computer.. Main thing his that he/she does not in any DOMAIN... I want NON-DOMAIN authentication.. any how.... please help...

Changing from Local to WCF


I've been handed an application thats connection string implies a local host connection.

I want to make this connection a remote connection, to a database located on a Server.  I want the client and server to be able to communicate with one another remotely, instead of a local connection.

How does one create the Data Service, and establish end points to Server and Client?  Is it as simple as creating a contract (which I have limited knowledge on constructing), between the two locations, setting up the dataservice, security, and ratifying the 'connetions'?

A smidge of insight, please ;-)



Ive 'inherited' some code that creates a HttpWebRequest object to consume a webservice and am working through it to figure out what each bit does.  Ive never consumed webservices this way before (I always create a webreference) so this way of working is new to me.  I can follow all of it except for one bit.  Heres the code Im having trouble understanding

ASCIIEncoding encoding = new ASCIIEncoding();
byte[] bytesToWrite = encoding.GetBytes("The message here");

// create web request
const string Action = "http://Awebaddress.org/AProcess"; 
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("The web service url here");

const string contentType = "text/xml; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = contentType;
httpWebRequest.Timeout = -1;
httpWebRequest.ContentLength = bytesToWrite.Length;

the line im having trouble with is this one

Data Points: Windows Azure Table Storage - Not Your Father's Database


Let go of your traditional relational database thinking if you want to understand how Windows Azure Table storage works, says Julie Lerman. Luckily for you, she's done the hard work to grasp the new concepts and help you get up to speed.

Julie Lerman

MSDN Magazine July 2010

Cloud Storage: Fueling Your Application's Engine with Windows Azure Storage


Yes, you can run background processes in the cloud. Kevin Hoffman and Nate Dudek use a shopping cart example to demonstrate how to build an application engine as well as implement asynchronous messaging and processing using Azure Storage.

Kevin Hoffman, Nathan Dudek

MSDN Magazine January 2010

Foundations: Workflow Services for Local Communication


This month's column describes how to use WCF for communication between a workflow and a host application in Windows Workflow Foundation 3. This knowledge should help developers with their efforts using WF3 and prepare them for WF4, where WCF is the only abstraction over queues (referred to as "bookmarks" in WF4) that ships with the framework.

Matthew Milner

MSDN Magazine November 2009

CLR Inside Out: Isolated Storage In Silverlight 2


See how to get the most out of isolated storage in Silverlight to keep your applications safe.

Justin Van Patten

MSDN Magazine March 2009

Data Points: Syndicated Data And Isolated Storage In Silverlight


Here we build a syndicated news reader application to illustrate the use of isolated storage and data syndication in Silverlight.

John Papa

MSDN Magazine February 2009

Smart Storage: Protect Your Data Via Managed Code And The Windows Vista Smart Card APIs


Smart cards are a compelling alternative to the reliance on passwords, which are the weakest link in authentication systems. Get the Windows smart card programming basics here.

Dan Griffin

MSDN Magazine November 2006

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend