Out of Browser Feature
Silverlight 3 applications are no longer restricted to running in a browser. They can be run in a browser or it they can be detached from the browser and run from the desktop. These out-of-browser applications allow you to bring the richness of Silverlight 3 applications directly to the desktop without the restriction of running within a browser. With the release of Silverlight 3 Beta 1, Microsoft introduced the ability for Silverlight applications to run outside the browser. These “Out Of Browser” (OOB) applications are installed on the desktop, and have associated shortcuts just like traditional Windows applications. Silverlight OOB applications are still limited by the same security sandbox as their "in-browser" counterparts, so all the security and local access rules still apply as if they were running inside of a browser.
Offline Feature
While the OOB feature is really useful, Microsoft also introduced the capability to run OOB applications offline. There are several different implementations and options for Disconnected Silverlight OOB applications, but updating an existing Silverlight 3 application to run disconnected can be achieved in just three easy steps. We will look at these steps further in this document.
Detaching the application: The first time users view the application, it will be in the web context in a page. If the application is enabled for OOB experiences, the user can detach the application. There are two ways through which you can detach the application to run in OOB mode, as follows:
1. Through the right click context menu
2. Via a user-initiated action (e.g. context menu or button click or some function in the application that calls Application.Current.Detach()).
This action takes the browser and creates an OOB application as follows.
- The application (XAP) is requested again via the browser
- The XAP gets stored locally in a low trust location along with metadata, which includes the origin URI of the XAP as well as metadata, most importantly for this discussion the ETag information of when it was downloaded (essentially a timestamp).
Launching the OOB application:
If we close the application and launch it again from the desktop, it initiates a startup of the application. In this instance, the application looks at its metadata for the origin URI of the XAP and makes a request therewith. It compares the HTTP response data (code and ETag) for comparison. If the application wasn’t updated, then the application launches and all is well. In fact, inspecting the request it would look something like this for our application:
Here, in line no. 09, we can see the response “HTTP 304 Not Modified”. No further information is sent and we can see that no content was even delivered, because the application hasn’t changed. At the API level, we can detect the changes made in the application since its last run using the ExecutionStateChanged event handler, and checking if the current ExecutionState is ExecutionStates.DetachedUpdatesAvailable, in the App.xaml file.