WebBrowser control and basic authentication on page retrieval.

A

Andrew Bools

I have an interesting problem with the Microsoft
WebBrowser object.

I want to run a copy of the WebBrowser control in my
application and retrieve a specified Web Page without
user intervention. I can do this OK, but when the page
requires basic authentication credentials I have a
problem.

My test web site requires (the same) authorization for
all data it provides, you can't even get the first HTML
file without authorization.

My test page consists of a short HTML file that contains
several frames that are loaded from other HTML files (a
fairly common structure I beleive).

I put the credentials in my request as follows:
Call the Navigate2 method specifying the Authorization
header.
Whenever the BeforeNavigate2 event fires, specify the
same Authorization header.

However, my request fails.

If I don't run the Browser in Silent mode, it seems to
get the HTML (which means that it used the authorization
header i gave it). Then when it wants to get the frames I
get prompted for the username/password (which is exactly
what I don't want, as I don't want any user intervention).

If I run the browser in silent mode, it seems to get the
HTML and then the request fails (Cannot find server or
DNS error).

My question (eventually) is this:

Is there any way that I can get teh Authorization
credentials that I specified at Navigate2 (or
BeforeNavigate2) to be used when the WebBrowser retrieves
HTML and objects for the page?

I have been looking at this for a while now, and cannot
see any way around it, which means that my application is
a non starter, as there lust be no user intervention.

Thanks in anticipation;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top