IXMLHTTPRequest2Callback::OnRedirect method

Occurs when a client sends an HTTP request that the server redirects to a new URL.


HRESULT OnRedirect(
  IXMLHTTPRequest2 *pXHR,
  const WCHAR      *pwszRedirectUrl



The HTTP request object being redirected.


The new URL for the HTTP request.

Return value

Returns S_OK on success.

Note  This callback function must not throw exceptions.


If the request redirection is not permitted, you can call the Abort method on the pXHR object.

XMLHTTPRequest2 imposes a maximum of 100 re-directions on any request. Any re-directions above that limit generate an OnError event. Applications have no access to the headers for re-directions.

Once the final redirection has completed and the final URL has been reached, the application receives an OnHeadersAvailable callback.


Minimum supported client Windows 8 [desktop apps | UWP apps],MSXML 6.0 and later
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header msxml6.h

See also

Abort Method


OnError Event

OnHeadersAvailable Event