IXMLHttpRequest send returns E_ACCESSDENIED instead of 301 error

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="color:#333333; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; font-size:13px; line-height:16px
<p style=" Hello,
<p style=" When calling send in an IXMLHttpRequest to access a URL from a server that responds with the 301 error "permanently moved", send fails with the error E_ACCESSDENIED, meaning the password is incorrect. But the site doesnt require a password.
When trying to access this URL from a web browser or wget, the program will receive the 301 error and redirect to the correct URL. I cant seem to get the correct url since send fails. What should happen is that send should succeed and the
status member should be set to 301, with the status string containing the correct URL. Here is my code:
<p style="
<div style="color:Black;background-color:White; <pre>
#import <msxml6.dll>

<span style="color:Blue; using <span style="color:Blue; namespace MSXML2;

...
IXMLHttpRequestPtr pIXMLHTTPRequest = NULL;
HRESULT hResult;
pIXMLHTTPRequest.CreateInstance(__uuidof(XMLHTTP60), NULL, CLSCTX_INPROC_SERVER);

CString strUrl = _T(<span style="color:#A31515; "http://www.nytimes.com/services/xml/rss/nyt/start-ups.xml");

BSTR bstrUrl = strUrl.AllocSysString();

hResult = pIXMLHTTPRequest->open(L<span style="color:#A31515; "GET", bstrUrl, _variant_t(VARIANT_FALSE), _variant_t(<span style="color:#A31515; ""), _variant_t(<span style="color:#A31515; ""));

hResult = pIXMLHTTPRequest->send(_variant_t(<span style="color:#A31515; ""))
[/code]

<p style=" This code has been working fine with correct URLs, but Id like to be able to handle the errors and redirect to the correct URL. Any help would really be appreciated.
<div style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; padding:0px; margin:0px; border:0px initial initial
Thanks,
<div style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; padding:0px; margin:0px; border:0px initial initial
Alex


View the full article
 
Back
Top