InternetSetCookie() replacement?

G

Guest

I am in the midst of converting a .NET 1.1 app to 2.0, and have run across a
section where the old programmers were using [DllImport("wininet.dll")] to
get to InternetSetCookie().

Is there a way to do this natively in .NET 2.0?
 
V

Vadym Stetsyak

Hello, RWF!

R> I am in the midst of converting a .NET 1.1 app to 2.0, and have run
R> across a section where the old programmers were using
R> [DllImport("wininet.dll")] to get to InternetSetCookie().

R> Is there a way to do this natively in .NET 2.0?

Look at HttpWebRequest.CookieContainer

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
N

Nicholas Paldino [.NET/C# MVP]

This isn't necessarily the same as using the CookieContainer.

If you are trying to set cookies that are used for the duration of a
request, then yes, this is the same.

However, InternetSetCookie was also used to write persistent cookies to
disk for IE/WinInet's use. Cookies that come back from
HttpWebRequest/HttpWebResponse will not be persisted to disk if an
expiration date is set.

If you have the desire to write cookies to this store, then you have to
call this method through the P/Invoke layer.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top