Silverlight 2 includes a nifty new feature called Deep Zoom which lets you post a very large photo on the Internet which then exhibits remarkably responsive zooming and panning capability.? Microsoft’s demonstration project is the Hard Rock Cafe memorabilia wall.? Given my ongoing interest in travel photography, Deep Zoom immediately caught my eye.? I watched the MIX08 video featuring Scott Stanfield and then recently attended his Bay.NET presentation in San Francisco in June.
I just happened to have a few panorama photos which I have taken over the years (but never really done much with).? So I dug out these photos and using PTGui, a stiching application recommened by Scott, I combined my photos into some large panorama images.? Then after some minor touching up in Photoshop, I used the Deep Zoom Composer to prepare these panoramas for use with Silverlight.? You can see the results at www.travelswithcal.com/deepzoom/
The key to a successful DeepZoom photo is a large enough image that allows zooming in to some meaningful level.? If you just take a standard 8 - 10 megapixel photo,? a user won’t be able to zoom in for very far until the image begins to seriously degrade.? (In this respect, I strongly recommend putting an upper limit on the permissible zoom since it makes very little sense to allow a user to zoom in beyond the point where the image begins to completely deteriorate.)? ? Given that most stitching software recommends between a 33 and 50 percent overlap between the photos to be combined, I would estimate that in most cases a 3 or 4 photo composite would be the smallest possible image that would give you a satisfactory Deep Zoom result.? Obviously, the larger the original image, the more zooming that can be achieved.
A friend and I are planning to take some San Francisco photos on July 26 with a view to creating some Deep Zoom panoramas.? What we are hoping to determine is whether following the correct procedures for image preparation can lead to some stunning results.? Stay tuned.
Recently I was involved in a project that used Silverlight v2 beta 1, SQL Server 2005, and a WCF service using LINQ in an ASP.NET v3.5 project. A link to an article describing this project will follow soon.
When looking for the most affordable web host that would support this application, fellow blogger & Silverlight aficionado Alan Cobb
GoDaddy's Windows Economy Plan
seemed to fit the bill, it gave me access to 1 SQL Server 2005 database, ASP.NET v3.5 support, running under IIS v6 or v7 for around $9 for two months. That's a price that's hard to beat, but would it work? The short answer is yes, the long answer is that it requires some teeth pulling. I'll explain the gotchas, tips, and modifications necessary to successfully deploy such an application under GoDaddy's Windows Economy web hosting plan.
Silverlight MIME Types
When setting up a new web hosting account with GoDaddy, choose IIS 7
, not IIS 6. With a new GoDaddy IIS 7 plan all the necessary MIME
types should already be registered for you.
You may be asking, wait a minute, Silverlight is a client side technology, it should be supported on any web server, right? Well that's mostly correct. It is supported on any web server, as long as that server has the Silverlight required MIME types registered. When the Silverlight plug-in requests certain assets (such as .xaml or .xap files) it requires the web server hosting those files to have the correct MIME types registered for those file extensions. Every web server worth a grain of salt lets you configure MIME types. Though every web host, may not give you direct access or the ability to do so.
The Silverlight related MIME types include:
|Extension ||MIME Type
MIME type is mostly used by Silverlight v1.0 applications.
file is where all the Silverlight v2 assets are stored. It's stored in the "ClientBin" folder in a Silverlight v2 application. It's actually just a ZIP file, you can open it in any .ZIP capable application to see what's inside. The files inside typically include a .xaml file (the UI), Silverlight assemblies (.dll files), and embedded resources (.jpg,.wmv, etc..).
MIME type is not necessary for Silverlight applications, but could be useful if you wish to deploy WPF XBAP
When I initially created my GoDaddy account, I set it up as an IIS 6 account. I'm much more familiar with IIS v6 than v7, so I chose IIS v6 with the thinking that it's better to go with the devil you know. The IIS v6 account did not have the .xap MIME type registered. The symptom was that the Silverlight plug-in loads fine, but the application shows up as a blank white canvas, as the plug-in can't/didn't download the .xap asset properly. Tip to Microsoft: If the .xap asset can't be downloaded/processed properly in a timely manner, please show an error message, a blank white canvas is a bit disconcerting.
If you already have or must have IIS 6 under GoDaddy (if you need FrontPage Extensions, ColdFusion support, or have other reasons such as this
), the following are your choices:
- Contact GoDaddy support and have them add the necessary MIME types for you. Some have had good luck with this, I did not.
<Bad Customer Experience Rant Start>
First, you should know, any support ticket under the Economy plan takes up to 24 hours to process (usually fewer than 12 hours). I guess you get what you pay for. Second, when I put in a ticket for them to add the MIME types they responded by e-mailing me information on how to do so myself using a web.config under IIS 7. That's all fine and dandy, but I was on a IIS 6 account, and the ability to configure MIME types using web.config files is only supported under IIS 7. So I got my support ticket re-opened and escalated. They responded that the MIME type would be added within 12 hours. After 12 hours, when my Silverlight application still did not work, I called in again and they informed me that the techs said the MIME type has been configured. When I explained that it had not been done properly, the rep, in not so many words, said, it is configured properly, I can't talk to the IIS admin directly, and that I don't know how MIME types work under GoDaddy. At this point I said screw it, I'm not going to get anywhere with this doofus, I told him to migrate me to IIS 7. Migrating from IIS 6 to IIS 7 under GoDaddy means canceling out my current IIS 6 web hosting account, getting a refund, and signing up for a new hosting account, this time choosing IIS 7 when setting up the account. After this was done, I was able to run simple Silverlight applications just fine without any additional configuration.
</ Bad Customer Experience Rant End>
- Brad Abrams suggests a workaround where you rename the .xap file to .zip, and change the reference to the new extension in the application's .xaml file, and in the .aspx/.html file that hosts the Silverlight control.
If you're on another web host that's running IIS 7, but doesn't give you direct access to IIS MMC, you can configure mime types using a web.config file using this guide
. Don't do this on a GoDaddy IIS7 account! Placing these directives in a Godaddy IIS 7 account, which already has these MIME type configured, will cause the server to spit out server configuration errors. Under IIS 6, these directives are ignored.
If you're hosting on your own IIS server, or on a different web server that gives you full access to the IIS 6/7 MMC, read this link
for information on how to configure the MIME types.
WCF Services on web hosts with Multiple IIS Identities (GoDaddy)
WCF services hosted on IIS can only have one base address. Under some hosting configurations, such as GoDaddy's shared Windows Economy Plan, multiple base addresses exist. When attempting to access WCF services on an IIS with multiple base addresses, an exception similar to the following occurs:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
The solution, using a combination of information found here
, is to create a custom service factory and override the "CreateServiceHost"
method. For Godaddy, I need to have it return the second base address found. The code below only returns the second base address when more than one exists, otherwise I return the first base address. This way I can share the same code base when using my local IIS/ASP.NET server, and GoDaddy IIS servers You may need to modify this code to return a different/custom base address depending on your application's needs.
Simply add the following class, as a sister class, in the service code behind file (yourservice.svc.cs):
protected override ServiceHost CreateServiceHost(Type serviceType, Uri baseAddresses)
// If more than one base address exists then return the second
// address, otherwise return the first address
if (baseAddresses.Length > 1)
return new ServiceHost(serviceType, baseAddresses);
return new ServiceHost(serviceType, baseAddresses);
Then edit the markup in the .svc file (yourservice.svc), by adding the following attribute to the "ServiceHost"
(You can edit this file in any text editor, or by right-clicking on the file in Visual Studio 2008 solution explorer, and choosing the "View Markup"
WCF .svc files and GoDaddy
For some reason GoDaddy's IIS 7 server configuration doesn't have the buildprovider extension configured for the .svc file extension. This is easy enough to fix. Simply go to the ASP.NET project application folder and open up the web.config
file, under the "<compilation>"
tag, which is under the "<system.web>"
tag, add the following directive:
<add extension=".svc" type="System.ServiceModel.Activation.ServiceBuildProvider,
System.ServiceModel, Version=18.104.22.168, Culture=neutral,
Setting up SQL Server on GoDaddy
has information how to create a SQL server database on the GoDaddy account. When you set up the database, you don't need the "DSN"
option, as that's for older ODBC connections, which we won't be using. You should check/include the "ASP Schema"
option. Don't worry, if you missed these options when you set up the database, you can go edit the database properties through GoDaddy's interface to add/remove these options as needed.
Exporting local SQL Server database to GoDaddy
If you wish to export a local SQL Server 2005 database schema/data to GoDaddy follow the infromation provided here
Configuring LINQ/ASP.NET/WCF to connect to the GoDaddy SQL Server
Setting up IIS Application folder on GoDaddy
- Find the database host address, database name, user id, and password for the SQL Server you wish to connect to. Information on how to do that is here
- Edit the web.config and find the "<connectionStrings>" section, change the "connectionString" attribute to:
connectionString="Server=SQL_HOSTADDRESS; Database=SQL_DBNAME; User ID=SQL_USER_NAME; Password=SQL_DB_PASSWORD; Trusted_Connection=False"
For ASP.NET application to work correctly, the folder that it's contained in must be set as an application folder. To do this on GoDaddy:
Configuring a Cross-Domain Policy File (clientaccesspolicy.xml)
- Logon to the web hosting account ("Hosting & Servers" menu, "My Hosting Account" sub menu item).
- Click on the "Manage Account" link next to the domain you wish to configure.á
- Under the "Content" menu item, choose the IIS Settings sub menu item.
- Click on the "Create" button and set the "Directory Name:" textbox value to the same name as folder you wish to place the ASP.NET application in.
- Make sure to select the "Set Application Root" option.
- Press the "OK" button.
If you wish to debug a Silverlight application, which accesses an on-line server's WCF service, through a locally running instance of Visual Studio, you must configure a cross-domain policy file. You may also need a cross-domain policy file configured if the base address returned by "CreateServiceHost"
is not interpreted as a local address by the WCF service (covered in the "WCF Services on web hosts with Multiple IIS Identities (GoDaddy)" section above).
For a full explaination of how to create cross-domain policy files, this article
is a good read.
Karen Corby's three part article on site of origin
, cross domain communication
, and configuring a cross domain policy file
is also a good read on the details of how Silverlight handles communication.
Uploading the project
I always found it surprising that there's very little documentation detailing which files are actually need for a deployed application to run. When you look at the solution file you will see many files (.sln, .csproj, .aspx, .dll, .dbml, .cs, .svc, folders, etc...). But to deploy an application only a few of these files and folders are needed.
The folders/files that actually needed for an application to run include:
Reconfiguring Silverlight WCF Service Reference Location
- Any .aspx and/or .html files that the application uses. A Silverlight web application project usually creates a default.aspx and default.html, which aren't actually used/needed for anything. You probably will want to rename the startup .aspx or .html file to default.aspx or default.html. When the startup file is named "default.aspx/default.html" then users can access the application without specifying the application file name (http://www.yoursite.com/yourappfolder/ instead of http://www.yoursite.com/yourappfolder/yourapp.aspx).
- The WCF .svc file, this file associates a service with its implementation and is the means for IIS to create a ServiceHost for you. For further reading, this article details hosting and consuming WCF services.
- The "web.config" file in the web project folder. Information on the web.config file can be found in many places, including here, here, and here.
- The "bin" folder (ASP.NET assemblies) in the web project folder.
- The "Clientbin" folder (Silverlight assemblies/assets) in the web project folder.
- Any assets referenced by Silverlight, HTML, and ASP.NET sources, such as images, videos, etc...
If the Silverlight application is currently pointed to a locally hosted WCF service location, and you wish to point it to an on-line/different WCF service location, the process is simple.
- Go to the Visual Studio Solution Explorer, and right-click on the server reference (under the "Server References" folder)
- Choose the "Configure Service Reference" menu item.
- Set the "Address:" text box value to the URL of the WCF .svc file (http://www.yourserver.com/yourappfolder/yourservice.svc).