RE: How to add cookie with axWebBrowser

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Walter:

Thank you very much, It's really the solution we need, we spent almost two
weeks on this problem, for we need a cookie item to implement loading balance
on server.

""Walter Wang [MSFT]"" wrote:

Hi Peter,

Welcome to MSDN Managed Newsgroup!

Due to WinInet design, WebBrowser's Navigate or Navigate2 cannot set the
cookies in the extra headers. You will need to use WinInet API
InternetSetCookie to workaround this:

Private Declare Function InternetSetCookie Lib "wininet.dll" _
Alias "InternetSetCookieA" _
(ByVal lpszUrlName As String, _
ByVal lpszCookieName As String, _
ByVal lpszCookieData As String) As Boolean


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
InternetSetCookie("http://server/asp/";, "test", "foo")
AxWebBrowser1.Navigate2("http://server/asp/test.asp";)
End Sub


In the asp/test.asp:

<% Response.Write(Request.Cookies("test")) %>


This should correctly display "foo" in the webpage.

Hope this helps.


Sincerely,
Walter Wang (wawang@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • RE: Forms Authentication - Sudden Redirect Failure on Login
    ... HttpCookie cookie = new HttpCookie ... Yields the problem on ALL platforms, the redirect does not happen. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: How to add cookie with axWebBrowser
    ... ByVal lpszCookieName As String, _ ... Microsoft Online Community Support ... The MSDN Managed Newsgroup support offering is for non-urgent issues ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vb.controls.internet)
  • Re: login control persistent cookie problem
    ... and the cookie lasts forever. ... There is no timout setting in the web.config. ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Setting Cookie.Expires
    ... As for the Cookie expire time, it does have been set on the cookie (you add ... Microsoft MSDN Online Support Lead ... from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: use SOAP header for asp.net session state
    ... HttpWebRequest class to send/receive webservice request/response SOAP ... cookie returned from server-side ASP.NET webservice. ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.webservices)