Deep linking isn’t a common term – it’s strange and when I heard it for the first time, I was actually giving a talk. Somebody wanted to know from me whether Silverlight supported deep linking.
I couldn’t give an immediate answer and eventually said I don’t know. That was then, but now I do know the answer isn’t a definite yes but rather sort of. Technically, the answer is no.
But with most things, nothing is set in stone and there is a way. It was last night that I spent a few evenings trying to find answers. Before coming to any solutions, here is more or less what deep linking is all about for anybody who is new to this sort of thing.
On a regular kind of website, the URL in the browser is linked closely to the content you’re viewing. If, for example, you were to click on the about link on somepage.com, you would in all likelihood go to http://www.somepage.com/about. The link identifies that content.
In a Silverlight application, the content is sometimes loaded by another container. The URL doesn’t change. Deep links are a type of link that direct users to an app as opposed to a store. They save users the time of having to hunt for a certain page.
Deep links are important because they’re an important marketing tool as they can increase your conversion rate. There are a few ways for it to work with Silverlight. Silverlight 2 for instance is an exciting Rich Internet Application platform for the .NET developer.
It has a disadvantage though when compared to the regular page-based model of the Web. It doesn’t have support for using the browser’s buttons to navigate within the Silverlight application and for bookmarking the state of a Silverlight application.
There is the risk that the state of a Silverlight application can be lost simply by refreshing its host page. Silverlight offers lots of useful features – animations, binding, layout system, and others. The mere fact that it’s a browser plug-in leads to limitations for the user. One is the lack of Deep Linking. The browser’s address bar contains the starting page for the application but changes aren’t reflected in the address. The address bar and buttons are appearing in applications so fixing them in the browser is important.
A common issue with Silverlight is that the user will sometimes click accidentally on the browser back button. Action on Silverlight doesn’t cause the browser to record it.
Silverlight comes with classes that help us with the Html container of the plug-in.
There is a commercial example from Asual. There are lots of people solving the problem for AJAX and Flash so I decided to take a jQuery dependency, wrapping a jQuery plugin that handles deep linking.
The jQuery dependency is a smaller price to pay than an ASP.NET dependency. The wrapper is straightforward and the only friction will be in the deep linking problem Include jQuery and jQuery.history in the page that hosts your Silverlight.