HTMLDocument , Access denied - URGENT !!!

  • Thread starter Thread starter kavitha
  • Start date Start date
K

kavitha

Hi All,

I have code like here below. I am trying to load a
HTMLDocument from a url (file or http).
I tried createDocumentFromUrl() as well as open() but no
result.
I just need a HTMLDocument for a url, it will solve my
prolem. URGENT !!

SOMEBODY HELP ME.

HTMLDocument doc = new HTMLDocumentClass();
IHTMLDocument2 idoc = (IHTMLDocument2) new HTMLDocument();

/*
//For someone, doing this solved the problem
idoc.write("<HTML></HTML>");
idoc.close();
*/

// this line is throwing
// 1. UnauthorisedException: Access denied for urls of
//type "C:\test.html" or "http://localhost/test/test.html"
// 2. NullReferenceException second
// argument is anything other than "print"
idoc = doc.createDocumentFromUrl
("http://localhost/test/test.html", "print");

----------------------------------------------------

HTMLDocument doc = new HTMLDocumentClass();
IHTMLDocument2 idoc = (IHTMLDocument2) new HTMLDocument();
// This line is retriving the document but its
// readystate is always loading, how will it come to
// complete state?
idoc = (IHTMLDocument2) doc.open
("http://localhost/test/test.html", "_self", null, null);



Kavitha
 
kavitha,

I don't think that you should not be using createDocumentFromUrl method.
Rather, I think that you should be using the IPersistMoniker interface
through unmanaged code to load the contents from a moniker (named resource
like a Url). This is ultimately how the contents are loaded in MSHTML.

Once you can create the moniker (through the CreateUrlMoniker or
CreateUrlMonikerEx functions), you can pass it to IPersistMoniker and it
will load the resource.

Also, you aren't trying to do this in an ASP page perhaps, are you?

Hope this helps.
 
Hi Kavitha

Use shdocvw.dll (InternetExplorer class) & (MSHTML.tlb) MSHTML Object
library
This is the vb-code (VB6) that does it

Dim x As New InternetExplorer, y As HTMLDocument
x.navigate "C:\Python23\Doc\tut\node3.html"
Set y = x.document

Here y is the document class in which you get the entire HTML Content of the
document in an object form
for e.g

if you write msgbox(y.links(0).outerHTML), this will show you the text
behind the first link on the page that you loaded
Hope this example, helps you to usue it in C#

It must be similar in C#, tell me if it works

HTH
Kalpesh
 
Back
Top