Modify Request Header

  • Thread starter Thread starter Dave Slinn
  • Start date Start date
D

Dave Slinn

I have a VB app hosting the Webbrowser control. I would like to add
"something" to the requests that app is submitted to our web application to
indicate that its from this webbrowser and not a separate instance of IE.

Is this possible, keeping in mind that I cannot add anything to the
registry, since a user may still use IE to visit the web app.
 
Dave,

It is different for the axWebBrowser 1.x than for the WebBrowser 2.0.
Basicly it is setting using the interface the designmode to on and off.

This for the webbrowser 2.0

DirectCast(WebBrowser1.Document.DomDocument,
mshtml.IHTMLDocument2).designMode = "On"

Be aware that it has some strange side effects.

I hope this helps,

Cor
 
Hi Dave,

Welcome to MSDN newsgroup.
As for the modifying request header question you mentioned, based on my
research, the IE WebBrowser control's Navigate2 method can help specify our
custom http headers when we want to navigate to a certain web document. e.g:

private void btnNavigate_Click(object sender, System.EventArgs e)
{
object obj = null;
object url = txtUrl.Text;
object headers = "aaa:aaavalue\r\nbbb:bbbvalue";//"Accept-Language:
en-us,zh-cn,fr-FR,de-DE;q=0.5";

axWB.Navigate2(ref url, ref obj, ref obj, ref obj,ref headers);
}


Also, the IWebBrowser control also has the "BeforeNavigate2" event which
fires before navigate to a certain document, however, based on my testing,
we could only get the custom headers we specify in Navigate2 method there,
we can not reassign or modify the headers there. Regarding on this event,
I'll do some further research to see whether it is the by design behavior
or anything else to workaround it. (I test use the activeX control rather
than the .net 2.0's managed webbrowser control....)

I'll update you when I get some further information...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




--------------------
| From: "Dave Slinn" <[email protected]>
| Subject: Modify Request Header
| Date: Sat, 10 Dec 2005 23:15:57 -0600
| Lines: 8
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| X-RFC2646: Format=Flowed; Original
| Message-ID: <[email protected]>
| Newsgroups:
microsoft.public.dotnet.framework.aspnet,microsoft.public.dotnet.framework.w
indowsforms.controls,microsoft.public.dotnet.general,microsoft.public.dotnet
..languages.vb,microsoft.public.dotnet.languages.vb.controls,microsoft.public
..inetsdk.programming.w
| NNTP-Posting-Host: mail.gms.ca 142.165.52.112
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.windowsforms.controls:26017
microsoft.public.dotnet.general:184249
microsoft.public.dotnet.languages.vb:308070
microsoft.public.dotnet.languages.vb.controls:8487
microsoft.public.dotnet.framework.aspnet:364071
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| I have a VB app hosting the Webbrowser control. I would like to add
| "something" to the requests that app is submitted to our web application
to
| indicate that its from this webbrowser and not a separate instance of IE.
|
| Is this possible, keeping in mind that I cannot add anything to the
| registry, since a user may still use IE to visit the web app.
|
|
|
 
Hey Dave,

I've got confirmed with our IE guys about the IE WebBrowser control's
BeforeNavigation2 event, the Headers parameter in this event is actually
marked as [in] parameter from COM perspective, so this is read only .... So
far we're limited to use the Navigate or Navigate2 method to make http
request with our custom configured http headers....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| X-Tomcat-ID: 164402880
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Mon, 12 Dec 2005 10:18:40 GMT
| Subject: RE: Modify Request Header
| X-Tomcat-NG: microsoft.public.dotnet.general
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.general
| Lines: 72
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.general:184289
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi Dave,
|
| Welcome to MSDN newsgroup.
| As for the modifying request header question you mentioned, based on my
| research, the IE WebBrowser control's Navigate2 method can help specify
our
| custom http headers when we want to navigate to a certain web document.
e.g:
|
| private void btnNavigate_Click(object sender, System.EventArgs e)
| {
| object obj = null;
| object url = txtUrl.Text;
| object headers = "aaa:aaavalue\r\nbbb:bbbvalue";//"Accept-Language:
| en-us,zh-cn,fr-FR,de-DE;q=0.5";
|
| axWB.Navigate2(ref url, ref obj, ref obj, ref obj,ref headers);
| }
|
|
| Also, the IWebBrowser control also has the "BeforeNavigate2" event which
| fires before navigate to a certain document, however, based on my
testing,
| we could only get the custom headers we specify in Navigate2 method
there,
| we can not reassign or modify the headers there. Regarding on this
event,
| I'll do some further research to see whether it is the by design behavior
| or anything else to workaround it. (I test use the activeX control
rather
| than the .net 2.0's managed webbrowser control....)
|
| I'll update you when I get some further information...
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
| --------------------
| | From: "Dave Slinn" <[email protected]>
| | Subject: Modify Request Header
| | Date: Sat, 10 Dec 2005 23:15:57 -0600
| | Lines: 8
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| | X-RFC2646: Format=Flowed; Original
| | Message-ID: <[email protected]>
| | Newsgroups:
|
microsoft.public.dotnet.framework.aspnet,microsoft.public.dotnet.framework.w
|
indowsforms.controls,microsoft.public.dotnet.general,microsoft.public.dotnet
|
.languages.vb,microsoft.public.dotnet.languages.vb.controls,microsoft.public
| .inetsdk.programming.w
| | NNTP-Posting-Host: mail.gms.ca 142.165.52.112
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.windowsforms.controls:26017
| microsoft.public.dotnet.general:184249
| microsoft.public.dotnet.languages.vb:308070
| microsoft.public.dotnet.languages.vb.controls:8487
| microsoft.public.dotnet.framework.aspnet:364071
| | X-Tomcat-NG: microsoft.public.dotnet.general
| |
| | I have a VB app hosting the Webbrowser control. I would like to add
| | "something" to the requests that app is submitted to our web
application
| to
| | indicate that its from this webbrowser and not a separate instance of
IE.
| |
| | Is this possible, keeping in mind that I cannot add anything to the
| | registry, since a user may still use IE to visit the web app.
| |
| |
| |
|
|
 
Steven,

In my idea is it possible to reach the headers as I wrote, although not with
MSHTML because they are located outside the DOM area.

Not checked.

Cor
 
doh,

I thought that I had done something like this somewhere.

I copied the document as a textfile and than I could write it to disk
withouth that confirmation that is needed with the normal exec. I think that
you can use this as well to change the header.

However it is a while ago that I did this.

Cor
 
Thanks for your input Cor,

Yes, I admit that webbrowser control or MSHTML interface is not the proper
one to do http message customzing, I'd rather prefer the HttpWebRequest.
However, it seems that user interactive is the most important part in
Dave's scenario.....

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Cor Ligthert [MVP]" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Modify Request Header
| Date: Tue, 13 Dec 2005 09:24:29 +0100
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Response
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.general
| NNTP-Posting-Host: ip3e830773.speed.planet.nl 62.131.7.115
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.general:184366
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| doh,
|
| I thought that I had done something like this somewhere.
|
| I copied the document as a textfile and than I could write it to disk
| withouth that confirmation that is needed with the normal exec. I think
that
| you can use this as well to change the header.
|
| However it is a while ago that I did this.
|
| Cor
|
|
|
 
Back
Top