Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi,

 

I want to post an XMLHTTPRequest to a server for the screen scrapping

purpose. but it always throws an exception . :confused:

{"The download of the specified resource has failed.\r\n" }
  [system.Runtime.InteropServices.COMException]:
{System.Runtime.InteropServices.COMException}
  System.Object: {System.Runtime.InteropServices.COMException}
  _className: null
  _COMPlusExceptionCode: -532459699
  _exceptionMethod: <undefined value>
  _exceptionMethodString: null
  _helpURL: null
  _HResult: -2146697208

This is the code I have written.

 

MSXML.XMLHTTPRequestClass lobjRequest = new XMLHTTPRequestClass();

string lstrNull = null;
object lobjNull =lstrNull;
string lstrBody="";

lobjRequest.open("POST","https://xxxxxxxxxxx, false, lobjNull,
lobjNull);

lobjRequest.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
lobjRequest.setRequestHeader("Referer","http://xxxxxxxx");

string lstrRequest="xxxxxxxxxxxxxxxxx";

lobjRequest.send(lstrRequest);
lstrBody = lobjRequest.responseText;

 

The same code works fine when the request is posted to an http url.

 

Is there any solution for this? I tried to use WinHttp. But it also

asks for a client certificate.

 

hope someone will help me. :rolleyes:

Edited by PlausiblyDamp
  • 2 weeks later...
Posted
Have you tried using the classes under System.Net and it's related namespaces rather than the COM objects? Have a look at the WebClient class or possibly the HttpWebRequest and the HttpWebResponse classes as they should be able to do this.

 

Thanx a lot. ill try dat way.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...