Microsoft SilverLight 2.0
Overview:
Silverlight is a new Web presentation technology that is created to run on a variety of platforms. It enables the creation of rich, visually stunning and interactive experiences that can run everywhere: within browsers and on multiple devices and desktop operating systems.
Silverlight is not only an appealing canvas for displaying rich and interactive Web and media content to end users. It is also a powerful yet lightweight platform for developing portable, cross-platform, networked applications that integrate data and services from many sources. Furthermore, Silverlight enables you to build user interfaces that will significantly enhance the typical end user experience compared with traditional Web applications.
Silverlight enables you to create a state-of-the-art application that has the following features:
•It is a cross-browser, cross-platform technology. It runs in all popular Web browsers, including Microsoft Internet Explorer (version 6.0 and 7.0), Mozilla Firefox, and on Microsoft Windows and Apple Mac OS X.
•It is lightweight browser plug-in.
•It enables rendering of richer user experiences that are defined by XAML.
•It enables programming that is consistent with the Web programming model.
•It streams video and audio.
•It includes compelling graphics that users can manipulate—drag, turn, and zoom—directly in the browser.
•It reads data and updates the display, but it doesn't interrupt the user by refreshing the whole page.
Content for a Web page that contains Silverlight elements can be created by using the following tactics:
•Inline XAML and JavaScript.
•External XAML files and JavaScript files.
•Compressed content package that contains XAML, managed code, images, fonts, and media. Streaming media sources can be referenced from the XAML media elements.
Software Required:
Following software required for developing silverlight application:
•Internet explorer 5.5 or above.
•Visual Studio 2008 sp1.
URL:
•SilverLight Developer “SDK-Silverlight.2.0_Developer.exe”.
URL:
•Silverlight toolkit “Silverlight_Tools.exe”. (This will also install the Silverlight plug-in for Internet Explorer.)
URL:
Following software required for running silverlight application:
•Internet explorer 5.5 or above.
•SilverLight plug-in “Silverlight.2.0.exe”. (This will only install the Silverlight plug-in for Internet explorer.)
URL:
Installation Steps:
•Install visual studio 2008.
•Install patch (VS 2008 sp1) to update the visual studio 2008 to visual studio 2008 sp1. This patch will require 4GB free space only for running it.
•Install the Silverlight toolkit. During installation if the VS2008 SP1 is not installed on machine then following errors screen has been displayed.
If the SilverLight toolkit fails (Asking for installing SilverLight developer kit) and the following message screen is coming then do the following steps:
- Open a command-line window and navigate to where you downloaded the silverlight_tools.exe. Run the following command:
silverlight_tools.exe /X
- This should bring up a window like this:
Choose a location where you want the installer files to be extracted. Make note of that path.
- Now take the Silverlight.2.0_Developer.exe file you downloaded (Silverlight 2 Developer Runtime) and put it in the folder where you just extracted the tools bits.
- Now from the extracted folder, run SPInstaller.exe and the setup should run through installing the developer runtime and all the other required tools for development.
Configuration Steps:
Configure silverlight with Windows Server 2008 IIS 7.0:
- All MIME types neededto support Silverlight are implemented by default in Windows Server 2008 & 2003 IIS 7.0 and Windows Vista SP1. Windows Vista RTM customers can add mime types by running "IIS Manager", clicking on "Mime Types", then clicking "add" and adding the following mime types:
- .xap application/x-silverlight-app
- .xaml application/xaml+xml
- .xbap application/x-ms-xbap
Configure silverlight with Windows Server 2008 IIS 6.0:
- To enableIIS 6.0in Windows Server 2003 or IIS7 in Windows Vista RTMwith the appropriateMIME Types, add:
- .xap application/x-silverlight-app
- .xaml application/xaml+xml
- .xbap application/x-ms-xbap
1.Go toStart\Administrative Toolsand run IIS Manager, see figure below:
2. Right click on the server name and select "Properties", see figure below:
3. In the Properties Dialog, click on the "MIME Types" button, see figure below:
4. In the "MIME Types" Dialog, click the "New" button, see figure below:
5. In the "MIME Type" Dialog enters one MIME Type at the time:
- .xap application/x-silverlight-app
- .xaml application/xaml+xml
- .xbap application/x-ms-xbap
See figure below:
Creating a New Silverlight Application using VS 2008
Start silverlight application by selecting the File->New Project menu item within Visual Studio 2008 and use the New Project dialog to create a "Silverlight Application" (note: you will need to download and install the Silverlight Tools for VS 2008 release to get this support):
We'll name the project "Mysample". When we click the "OK" button Visual Studio will prompt us with an additional dialog that allows us to choose whether we want to create just a Silverlight Application project, or optionally also add a server-side ASP.NET Web project to our solution to host the Silverlight Application within. For this sample we'll choose to add an ASP.NET Web Application project to the solution as well and name it "Mysample_WebServer". When we click "ok" Visual Studio will create a solution for us that have both a Silverlight client application and an ASP.NET web server application in it:
When we do a "build" Visual Studio will automatically copy the compiled Silverlight application to our web server project (no manual step or configuration required). The default web server project that VS created for us contains both an ASP.NET page and a static HTML page that we can use to run and test our Silverlight Application within.
By default a newly created Silverlight application project contains a Page.xaml and App.xaml file, as well as code behind class files (which can be written in VB, C#, Ruby or Python) that are associated with them:
XAML files are XML text files that can be used to declaratively specify the UI of a Silverlight or WPF application. XAML can also be used more broadly to declaratively represent .NET objects.
The App.xaml file is typically used to declare resources, such as brush and style objects that are shared across the application. The Application code-behind class for the App.xaml file can be used to handle application level events - like Application_Startup, Application_Exit etc.
The Page.xaml file is by default the initial UI control that is loaded when the application activates. Within it we can use UI controls to define our user interface, and then handle events off of them within the Page code-behind class.
When we build our Mysample project, Visual Studio will by default compile the code and .XAML markup into a standard .NET assembly file, and then package it and any static resources (like images or static files we want to include in it) into a "Mysample.xap" file on disk:
Sample Silverlight Application CodeDetails (using c#):
The newly created Silverlight application project contains a Page.xaml and App.xaml file, as well as code behind class files that are associated with them. The “Page.xaml” file is used for particular web page and “App.xaml” file is used to applied changes in the whole application.
In sample application only one page is needed so all the functionality is in “Page.xaml” file and related code is in the code behind class file of the “Page.xaml” file. This application does the following tasks:
- OnPageLoad the sends the request to the server page “time.asp” and get the response. This process is schedule for every 20 seconds i.e. every 20 seconds send the request to the “time.asp” and got the response from it. After sending 3 requests it again sends the request to same page after 70 seconds (for getting the Site-Minder custom response).
- After getting the response, retrieves the necessary headers (status, content-type…) from response and check the “content-type” header from the response headers, it’s check that whether the response is in xml format or is in html format.
- If the response is in html format then get the response body by parsing it through Xml Dom Parser. And if the response is in html format then get the response body by parsing it through reader object.
- After getting response body, checks that whether the response body contains customsiteminder response or its actual response by searchingsiteminderattributes (SiteminderReason, SiteminderRedirectURL) in the responsebody.
- If the response body contains the Siteminder attributes then it works according to that attributes i.e. if the value of attributes "SiteminderReason" = "challenge" and "SiteminderRedirectURL" = "" thenredirect to the root URL else redirect to the URL that is presentin the "SiteminderRedirectURL" attribute.
- If the response body doesn’t contain any siteminder attributes then this bodyis simply written into the textbox.
- If there is any exception occur during processing, redirect to theroot.html page.
Silverlight files and its associated files are in the following zip file.
Steps to run Silverlight Application to test the Web 2.0 feature:
- Install the policy-server and do all the settings that are needed to protect the particular resource. After that add and change the parameter with the following parameter in the ACO parameter list:
<ACO Parameter Name> WebAppClientCustomResponse.
<ACO Parameter Value> Resource=/test/Time.asp|Method=GET|Status=200|Body=C:\Inetpub\wwwroot\output.txt|Content-type=text/html|Charset=us-ascii
- Install web-agent R12.5 with the web2.0 binaries.
- Publish the Silverlight application through VS-studio 2008 and then protect this application with form auth scheme. Also protect the “Time.asp” page using the form auth scheme.
- First access the Root page (Page containing the redirection link to the Silverlight application). This page is unprotected page.
- On clicking on the hyperlink, the credentials prompt arises, after filling the valid username and password the valid session has been created and Silverlight application start its processing.
Note:Session recreation will happen outside the Silverlight environment – in a plain browser environment.
- Silverlight application sends the request to “time.asp” page (This page is also protected) and get the response. Silverlight application sends first three requests with 20 seconds time interval and after that it send the request after 70 seconds time interval.
- If the response does not have SiteMinder attributes then the response with the necessary headers display in the textbox.
- If the response does have some SiteMinder attributes, but not RedirectURL and reason is “Challenge” then the Silverlight application redirect to the root page after displaying the necessary response headers, response body and custom response attributes. And come out from the Silverlight session.
- If the response has some SiteMinder attributes with RedirectURL then the Silverlight application redirect to the RedirectURL attribute and come out from the Silverlight session.
- Again on clicking on the hyperlink that is presents in the URLs the credentials prompt arises, after filling the valid username and password the valid session has been created and Silverlight application start its processing.
Samples
Under Web Server root document folder, create a folder with the name silverlight and publish the silverlight application in that folder.Copy the time.asp file in this folder.
Sample ACO Parameters (for Silverlight based application)
Parameter Name: WebAppClientResponse
Parameter Value: Resource=/silverlight/time.asp|Method=GET|Status=200|Body=C:\Inetpub\wwwroot\output.xml|Content-Type=text/xml
Resource=/silverlight/time.asp|Method=GET|Status=200|Body=C:\Inetpub\wwwroot\output.html|Content-Type=text/html
Parameter Name: MaxTimeoutURL
Parameter Value: smdevesx1vm42.ca.com/maxtimeout.html
Parameter Name: IdleTimeoutURL
Parameter Value: smdevesx1vm42.ca.com/maxtimeout.html
Parameter Name: OverlookSessionForUrls
Parameter Value: /silverlight/time.asp
Sample Pages