How to use IXMLHttpRequest2 with a network trigger (XAML)
Enables access to Web resources using an extension to XMLHttpRequest object.
Supports the ControlChannelTrigger object.
The following information applies to any connected or network-aware Windows Store app that depends on network connections using IXMLHTTPRequest2 to always be connected. The IXMLHTTPRequest2 interface provides access to HTTP servers and other web services. This topic applies to apps written in C++/XAML and apps using the .NET Framework 4.5 in C#, VB.NET, or managed C++ on Windows 8 and Windows Server 2012.
Some special considerations apply when using IXMLHTTPRequest2 with ControlChannelTrigger. There are some transport-specific usage patterns and best practices that should be followed when using a IXMLHTTPRequest2 with ControlChannelTrigger. Using ControlChannelTrigger does not affect the way that requests to send or receive HTTP requests on the IXMLHTTPRequest2 are handled.
- An IXMLHTTPRequest2 object when used as the transport has a lifetime of only one request/response. When used with the ControlChannelTrigger object, it is convenient to create and set up the ControlChannelTrigger object once and then call the UsingTransport method repeatedly, each time associating a new IXMLHTTPRequest2 object. An app should delete the previous IXMLHTTPRequest2 object before supplying a new IXMLHTTPRequest2 object to ensure that the app does not exceed the allocated resource limits.
- The app may need to call the SetProperty and SetRequestHeader methods to set up the HTTP transport before calling Send method.
- An app may need to make need to an initial Send request to test and setup the transport properly before creating the transport to be used with ControlChannelTrigger. Once the app determines that the transport is properly setup, the IXMLHTTPRequest2 object can be configured as the transport object used with the ControlChannelTrigger. This process is designed prevent some scenarios from breaking the connection established over the transport. Using SSL with a certificate, an app may require a dialog to be displayed for PIN entry or if there are multiple certificates to choose from. Proxy authentication and server authentication may be required. If the proxy or server authentication expires, the connection may be closed. One way an app can deal with these authentication expiration issues is to set a timer. When an HTTP redirect is required, it is not guaranteed that the second connection can be established reliably. An initial test request will ensure that the app can use the most up-to-date redirected URL before using the IXMLHTTPRequest2 object as the transport with the ControlChannelTrigger object.
For more information on using IXMLHTTPRequest2 with ControlChannelTrigger, see the ControlChannelTrigger with IXMLHTTPRequest2 sample.
For more information on how to create a lock screen app to receive background network notifications that use network triggers, see Quickstart: Create a lock screen app that uses background network triggers.
For more information on how to use network triggers to deliver notifications to a lock screen app, see How to use network triggers to deliver notifications to a lock screen app.
For more information on how to write a background task to receive background network notifications that use network triggers, see How to write a background task for a network trigger.
For more information on how to re-establish a network trigger and a transport connection, see How to re-establish a network trigger and transport connection.
For more information on guidelines and checklists for using network triggers, see Guidelines and checklist for using network triggers.
- Other resources
- Adding support for networking
- Background Networking
- Badge overview
- Connecting to a web service
- Lock screen overview
- Staying connected in the background
- Supporting your app with background tasks
- Tile and tile notification overview
- Toast notification overview
- Transferring data in the background
- Troubleshooting and debugging network connections
- Background task sample
- ControlChannelTrigger with IXMLHTTPRequest2 sample
- Lock screen apps sample
- Push and periodic notifications client-side sample
- Raw notifications sample