Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Visual Basic WebControl - Add a Header

Posted on 2006-11-19
8
Medium Priority
?
1,118 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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…
Suggested Courses

824 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