Solved

Visual Basic WebControl - Add a Header

Posted on 2006-11-19
8
1,080 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 19

Expert Comment

by:Daniel Van Der Werken
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 19

Expert Comment

by:Daniel Van Der Werken
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:davie455
Comment Utility
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 19

Accepted Solution

by:
Daniel Van Der Werken earned 400 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now