Link to home
Start Free TrialLog in
Avatar of davie455
davie455

asked on

Visual Basic WebControl - Add a Header

I am using the IE WebControl in a Visual basic container as a custom browser.  I need to pass some unique information via the browser to my web server and believe the best way to do this would be to read some local information (like a serial number in the registry entry for my browser app) into a HTTP header.    I have seem some posts about doing this on a link by link basis but I want this information to persist throughout an application session.

I am entirley new to software such as Visual Studio Express/Basic Express which has got me this far.....I simply want to a custom browser (which btw can only navigate my app) reporting something unique about the local installation to my web server so I can track installations.

Thanks
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

What you want to do is pass this information via your User Agent String (UAS).

Put the information in the following registry entry on the local workstation with the browser control.  You'll need to do this on every workstation.  

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform]
"My Unique User Agent String" = "Anything"

When the browser connects to the server, it will send this string along with its normal user agent string as part of the GET requests.  You can then parse the request to see if it's the browser you're interested in.
Avatar of davie455
davie455

ASKER

Thanks Dan7el,

I have used User Agent String as a method before in gecko browers such as k-meleon but not IE.

I have tested this by manually adding an entry to the registry and for sure the string name I enter appears in the headers although I cannot see the string value.  This solution would work for me but I want the WebControl/Visual Basic App to report a different User Agent String than standard IE.

To recap, the purpose of all of this is...

1.   I want my web app accessible only via this customer browser and not IE.   If the UA string does not match a database entry then IP and other details are logged and the user is politley told to go away.  Therefore i need the IE useragent to not include this custom string.

2.   Where the UA string does match a database entry i will know exactly which physical installation/device is accessing for each session as i will issue a unique UA string per installation.  (imagine on install of my VB app containing the webcontrol the user enters a serial which gets written to the registry entry you suggest as the UA and is valid for only one install.)

Hope this makes sense,

Thanks for your help
This page...

 http://support.microsoft.com/kb/q183412/

....seems to describe a solution which works when a link is clicked only.....I am 100% a newbie in the area of C++, Visual Basic or indeed any language other than ASP, HTML and JScript.   I have Visial Basic 2005 Express Edition, a single form containing a webcontrol and nothing else (defaul webcontrol URL is my app).  I need somebody to walk me through applying the right code literally click by click, I have tried but it's so new to me that my progress is poor.

Thanks



You don't want to do all that.

Looks like one of the overloads for the Navigate method will allow you to add a string that identifies the control.
yes perfect, a string which identifies the control where the string is variable and set at installation and only applies to the control and not IE.   So, an overload for the Navigate method, step by step how do I do that please?

Thanks
R
ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Dan7el,

I have put this code into Form1.vb in Visual Basic 2005 Express Edition, when I debug the code the window launches but there is a DNS error of somekind (right click the window and I get..."res://ieframe.dll/dnserrordiagoff_webOC.htm#http://www.google.com/" as the URL) .   Clearly I am missing something, apologies I really do have no experience whatsoever here...can you image what i am doing wrong?

From the moment I launch VB 2005 Express Edition and start a new project what should I do step by step?  In recognition of the extra detail I need i have increased the Point value.

Many Thanks again.

actually have this working now, when the vb app lauches the first page load the Header I set persists.....but on redirect and I assume A HREF links the customer header is lost...how can I ensure this persists.

Also, a 500 point question if somebody can give me an example of how to read a registry entry into the customem header.

Thanks
R