Link to home
Start Free TrialLog in
Avatar of hospidium
hospidiumFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Internet Explorer Web Browser Control Embedded

I am developing an application which primarily is built using vb.net, but takes advantage of the web browser control and shdocvw.dll.

I am using the Navigate2 Method to take me to a url. Now the problem I have is passing data collected by the VB application into the web control.

I have tried passing through the query string which originally worked, but compromises security within the application. As a result I tried to use something called
"navNoHistory" but to no real success.

I have also looked at the "PostData" section of the Navigate Method, but still have no luck. I am pretty much a beginner on .Net and running out of ideas on how to get this data through to my web page and web application.

I need a solution that will not allow the user to view posted data either through their browser history etc. Can somebody help as this is really taking time and I need to get this movng as soon as possible.

Thank You.
Avatar of SeanGraflund
SeanGraflund

if you turn off viewstate for the page you are redirecting too, you can access the values passed using Request.Form,
like in old asp and post pages.  
Avatar of hospidium

ASKER

Sean,

I am using the web browser control in vb.net and cold fusion as the scripting for the page. Once I have the data that I require to the web page I can take over with the cold fusion from there.

The key thing here is that the data is not seen by the user. The URL cannot be added to the history when navigation is complete. Is there code for this?
If you can post the form collection with the redirect, then you should be set ..

Example:

Response.Redirect("Page.cmf", true);

Then with the cold fusion page, just use the equivalent to Request.Form["objectname"] to get each value ..
Sean,

Do you have a code example of how I could acheive the whole process. Sorry don't quite understand at the moment.

Thanks
basically, the redirect method with that true parameter passed would send the entire form items collection with the redirect .. thus, you wouldn't have to use QueryStrings

Say for instance, you have a page with the following:

<form>
<asp:textbox id="text1" runat=server></asp:textbox>
<asp:textbox id="text2" runat=server></asp:textbox>

<asp:button id="cmdGoToColdFusionPage" runat=server text="Go"></asp:button>
</form>

now,

in the code behind for the button you'd do the following .. I don't think you'd need the dll at all that you are using .. you can do this completely in code ..

private void cmdGoToColdFusionPage_Click(object sender, System.EventArgs e)
{
   Response.Redirect("ColdFusionPage.cfm", true);
}


Then, in your cold fusion page, you can access everything through the forms collection like you would in old asp .. I'm not familiar how to do that in cold fusion, but in old asp you'd access it like the following:

Request.Form("text1")
Request.Form("text2")
Sean,

Here is the code that is being used.

me.ax1webbrowser.navigate2("url", flags, targetframe, postdata, headers)


Now in the URL I can pass the query string as well but that will be stored in the browser history, where values can be accessed. I am looking for a solution that will ideally stop this from happening or erase the history when the application exits, not using ASP. Remember that the application is a vb.net application with an embedded web browser activex control, using the shodcvw.dll library.

That is the solution I am looking for. Sorry If I did not make myself cler in the first place.

If someone can provide a solution using this method then that will be great! Thanks for your help so far
i think the parameter you need to pass is postdata, if you can somehow pass the forms collection to the postdata parameter, it will work ..
I have done this Sean and have no results. Any ideas? How I would construct the string etc. or some sample code for this.
you should just be able to send it Request.Form
this is not the solution I am looking for. Does every variable have to be specified when using the navigate or navigate2 method?

I want o really use the post data section of Navigate method. How would I get the data that I have into the postdata section of navigate and what format does it have to be? (e.g. string, object etc.)

It cannot be just string or object because the variables are not being passed. What can it be and how is it done?
Can nobody answer this question? Surely this has been done before?
I'm working on exactly the same problem.  If I can figure it out I will most definitely post my results here.  Sean doesn't quite grasp what is going on I don't think, since he keeps referring to server side ASP.NET stuff.

I've tried making a list of parameters and the converting it to a Byte array (the data type of the postdata parameter), but didn't have any luck.  I wasn't actually sure how to handle multiple parameters, or even what the format for a single parameter should be.  I am very surprised at how much documentation there ISN'T for this control.

Anyway, I'll update you if I figure out how to do it.
Thanks HummusX. I have been searching everywhere for this solution yet there are no examples of how to acheive this. Let me know if you have anything and likewise I will do the same. Thanks
HummusX and anybody else who needs to know. I have solved my problem. This is how I got round it...

 Private Enum BrowserNavConstants
        navOpenInNewWindow = 1
        navNoHistory = 2
        navNoReadFromCache = 4
        navNoWriteToCache = 8
        navAllowAutosearch = 10
        navBrowserBar = 20
        navHyperlink = 40
    End Enum

Dim BteArray() as Byte
Dim Url as String
Dim vHeaders As String = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)

Ok so that is the variables declared. Now we use the navigate2 or navigate method below...

url = "http://www.xxxxxxxxxxx.com/index.cfm"
BteArray = System.Text.Encoding.ASCII.GetBytes("username=xxx&password=yyy&answer=hjhjh")

'The System.Text.Encoding.ASCII.GetBytes was the namespace that does the work for us so after, our final navigation statement looks like below'

Me.WebBrowser.Navigate2(url,BrowserNavConstants.NavNoHistory,System.DBNull.Value,BteArray,vHeaders)

This will then complete the navigation and post the form data with it that you have collected in your application. Hope this helps people as I have been stuck on this problem for ages!!! and now it's solved!!

ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

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