Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Visual Basic WebControl - Add a Header

Posted on 2006-11-19
8
1,090 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:davie455
  • 5
  • 3
8 Comments
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 17981221
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.
0
 

Author Comment

by:davie455
ID: 17982183
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
0
 

Author Comment

by:davie455
ID: 17983143
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



0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 17983729
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.
0
 

Author Comment

by:davie455
ID: 17984143
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
0
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 400 total points
ID: 17984366
Imports System
Imports System.Windows.Forms.WebBrowser

Public Class Form1
    Private myByte(1) As Byte

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        myByte(1) = 0

        WebBrowser1.Navigate("www.google.com", String.Empty, myByte, "Additional Header Information")

    End Sub
End Class
0
 

Author Comment

by:davie455
ID: 17989541
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.

0
 

Author Comment

by:davie455
ID: 17991377
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
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
map interface methods 3 72
groovy example issue 10 103
Not needed 13 118
Bartender label printing - switch on and off graphics 3 54
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question