Use the csexwb webbrowser control to obtain HTTPOnly cookies

Source: Internet
Author: User

Due to restrictions of the Microsoft webbrowser control, HTTPOnly Cookies cannot be obtained by using webbrowser. Document. Cookie.

 

Solution: the expanded csexwb webbrowser control is used. The csexwb webbrowser control supports HTTP header monitoring. This gives us a way to read HTTPOnly cookie data,

 

Official Functions of the csexwb webbrowser control:

 

Csexwb Introduction

Csexwb is a C #. NET 2.0 control that creates, hosts and sinks the events of the original webbrowser control (not. net or any other wrapper ). advanced customization and total control over the webbrowser control are achieved via implementation of a number of interfaces, along with the addition of unsupported methods, properties, events and a com library.

 

Monitors HTTP requests and responses.Monitor HTTP and HTTPS request and Response Headers for all resources, images, sounds, scripts, etc, with the opportunity to add your own Headers

With this feature, we can obtain the original HTTP data of each request and what to do.

 

CodeThe excerpt is as follows:

 

Register an event

This . Cexwb1.protocolhandleronresponse + = New Csexwb. protocolhandleronresponseeventhandler ( This . Cexwb1_protocolhandleronresponse );
This . Cexwb1.protocolhandleronbegintransaction + = New Csexwb. protocolhandleronbegintransactioneventhandler ( This . Cexwb1_protocolhandleronbegintransaction );

 

Process HTTP headers in events

Private Void Cexwb1_protocolhandleronbegintransaction ( Object Sender, csexwb. protocolhandleronbegintransactioneventargs E)
{

}

private void cexwb1_protocolhandleronresponse ( Object sender, csexwb. protocolhandleronresponseeventargs e)
{< br> /// Record Analysis cookie
string headers = E. m_responseheaders;
/// ....... custom Code to process HTTP header data to obtain HTTPOnly cookies
}

 

 

Call starthttpapp () and starthttpsapp () to start monitoring, and call stophttpapp () and stophttpsapp () to stop monitoring.

Cexwb1.starthttpapp ();
Cexwb1.starthttpsapp ();

Cexwb1.stophttpapp ();
Cexwb1.stophttpsapp ();

 

The link on codeproject: http://www.codeproject.com/KB/miscctrl/csEXWB.aspx

Project homepage on googlecode: http://code.google.com/p/csexwb2/

 

This control is much easier to use than the webbrowser control that comes with Microsoft. The only disadvantage is that you need to register ActiveX components.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.