Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.Net.XmlHttpExecutor.getResponseHeader Method

Gets the value of a specified response header, based on the header's name.

Syntax

var statusText = MyExecutor.getResponseHeader();

Exceptions

Exception Type Condition

Sys.InvalidOperationException

The getResponseHeader property was accessed outside the event handler.

-or-

The getResponseHeader property was accessed after the completed event occurred.

Remarks

If the Web request completed successfully, you can call the getResponseHeader method to get the value of a specific response header based on the header's name. If the header does not exist, an empty string ("") is returned.

You can call the getResponseHeader method only in code that is running inside a completed event handler, or running in the call stack of the completed event handler. An exception is thrown if you call the getResponseHeader method when the executor did not return successfully, or if the XmlHttpExecutor.responseAvailable property returns false. An exception is also thrown if you call the getResponseHeader method after the completed event has occurred. This is because the executor releases its reference to the browser's XMLHTTP object.

Example

The following example shows how to get header data. This code is part of a complete example found in the Sys.Net.XmlHttpExecutor class overview.

JavaScript

// Get a specific header.
resultElementId.innerHTML += 
"Content-Type Header: " +
    executor.getResponseHeader("Content-Type") + 
    "<br/>";