Setting HTTP Headers

Set HTTP headers for the Hybrid Web Container to include authentication tokens.

These methods in the Hybrid Web Container template source code show how to set HTTP headers:
  1. In Visual Studio, open the CustomizationHelper class in the CustomCode folder.
  2. Override the getHttpHeaders method and uncomment its contents.
    The stub code shows how to add headers and cookies. Simply replace the header and cookie assignments with your own.
  3. Refresh the HTTP headers.
    It is a good idea to refresh the HTTP headers in the OnTokenError method , which is called when a Hybrid App token authentication failure occurs.
    Here is a common way to do this:
    1. Maintain member variables that contain the values for the headers you want to set.
    2. Override the GetHttpHeaders method to use the value in those member variables when it sets the headers.
    3. In OnTokenError, update the member variables with the new header values.
    4. Call UpdateHttpHeaders again.
  4. If you have custom code to run when an HTTP error occurs, add the code to override the OnHTTPError method.
    Your method is called any time there is an HTTP error. You can use it to inform the user of errors, or to perform other custom steps in response to particular error codes.