Cookie problems when using federated security and SignalR

I recently ran into a problem where the application I was working on didn’t pass the security information as expected to the server. The application in this case is a Silverlight client, with a WebAPI and SignalR backend. For security, we are using WIF…or federated security…I don’t know what to call it anymore. We aren’t really federating it today, but it is based on the same framework…

It has been a while since I was involved in the system, but I got roped back in to solve some issues. And while doing so, I discovered that I wouldn’t get a proper security context for calls made from the client to the server using SignalR. For some reason, those calls where just not being authenticated properly…

More...

Building a template selector in Silverlight

There are several “missing” features in Silverlight that people keep bringing up, or keep trying to find solutions for. One of them is the template selector, or DataTemplateSelector class to be more specific.

The DataTemplateSelector has a single responsibility, which is the way it should be. It is responsible for returning a DataTemplate based an object. Generally, it is used in lists, where the data template can be selected based on the bound item, and thus give different templates to different kind of objects in the list.

In Silverlight, this is not possible out of the box, and instead requires us to create multiple UI controls, and hide and show them using data binding. This approach works, but it easily becomes heavy and complicated, which is why I want a template selector that works…

More...

Exposing and consuming REST-based APIs with WCF WebApi and Silverlight

There are many ways to expose functionality and data from a server to a client. And there is probably almost as many going the other way… In Microsoft scenarios, using WCF is the obvious choice for most of us, and when people talk WCF, they generally talk SOAP based webservices.

SOAP can however be a less than ideal choice in a some cases. It is way more complicated than some of the other options, and on top of that it has a tendency to bloat the messages being sent, which can be an issue when working with mobile clients for example.

More...

SignalR and Silverlight

SignalR is a somewhat newish open source project that makes it possible to simulate push notifications on the web. It does so using long-polling (websockets available as an extra download), so it isn’t true push as such, but it gives the appearance of push. And on top of that, it is so ridiculously simple to set up…

Unfortunately, the NuGet package for SignalR doesn’t include the Silverlight client, which the GitHub project does. This is most likely going to be fixed in the near future, but currently you will have to do it the manual way instead of using NuGet.

The server part of SignalR works fine through NuGet, however, it doesn’t play nice with the Silverlight version as a property has been renamed and causes issues. So we have to do the whole thing manually to make sure both the client and server has the modified property… Once again, it is probably going to be fixed some time really soon.

More...

Custom type providers in Silverlight 5

Ok, after yesterdays less technical post, I guess it is time to get back to writing a real techy post. This time, it is even techy, or geeky, enough to be about Silverlight 5, which currently is still in beta.

This obviously means that we can’t use it, but it doesn’t mean that we can’t have a look at some of the new features and start thinking about how we can upgrade our existing applications as soon as the new version is released…

Custom type providers might sound really obscure, and to be honest, not very interesting. But that’s where you are wrong…

More...

WCF, Silverlight and T4…a good combination…

Ok, so this post is definitely going down in the books as “why would you do that” for a lot of people, but it actually has its benefits in some cases. What I want to show, is how we can work with WCF services and service interfaces without having to add a service reference to Visual Studio and instead auto generate the required code using T4 templates…

So why would I want to do that? Well, in some cases it is kind of tedious and even complicated to spin up the service just to be able to update the service reference and in some cases it isn’t even possible to get access to the WSDL that is required to create it. And in those cases, this will help you… In my case, the services and service contracts are built by one dev, and the Silverlight stuff by me. To us, this way of working makes it a lot easier to handle changes to the service contracts as we go along… I can get changes by just checking out the changed interfaces without having to try and get my solution into a state where I can update my service reference.

More...

Difference between Type.GetType() in Silverlight and .NET

I am currently working on a little thing in Silverlight and came across an interesting “feature”. The thing I am working on requires me to dynamically create types based on strings in a configuration file, and for this purpose, I created a simple TypeConverter called TypeTypeConverter. It is a very simple converter that takes a string and converts it to a Type. So I created a very simple implementation that looks like this

public class TypeTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}

public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
return Type.GetType((string)value, true);
}
return base.ConvertFrom(context, culture, value);
}
}

As you can see, it is probably a little TOO simple as it doesn’t handle errors at all. But to be honest, in my case it is actually a bit by design.

So why does this simple little thing end up on my blog? Well, because it failed… Not the code as such, but the thing I was trying to do…

More...

My view on HTML 5…and Silverlight

I continuously get questions regarding HTML5 and Silverlight. Especially after Microsoft’s somewhat brilliant comments at PDC. How is Silverlight going to survive now that HTML5 is coming? Why would you chose Silverlight over HTML5? Are you going to lose your job now that Silverlight is dying?

Well, I have finally decided to state my opinion  on my blog. It is obviously a biased opinion as I believe Silverlight to be a better choice in a lot of situations. So this is obviously a risky engagement, but I guess I will just have to endure the flaming I am going to get from a lot of people. Even a lot of people close to me.

But before I go too far, I do want to mention that we are living/working in an ever changing world. My opinions regarding the different technologies will probably change over time as the world changes. But this is my current view of the situation…

So…here we go…let the rant begin!

More...

Sharing resources and styles between projects in Silverlight

I have lately been working on a somewhat larger Silverlight application for a client here in New Zealand. The application is being built using PRISM, which means that it is loaded in a composite/ modular way. And with this modular/composite loading, being able to share resources between different modules becomes pretty interesting as it makes it easier to get all modules to share the same look and feel. So this got me to rehash a topic I have already talked about before, merged dictionaries.

This is obviously not a PRISM only thing to do, but it often becomes a little more sought after when the application starts getting spread out over several different projects… Luckily, it is very easy to share resources between projects in Silverlight.

More...

Another user group meeting

Next Wednesday, October 20th, I will be presenting at the .NET user group here in Wellington again. This time the talk is all about smooth streaming (same talk as I presented at TechEd NZ). It covers everything from encoding your media, to publishing it on your server and of course also how to consume it from Silverlight. It will also be covering how to get your first live smooth streaming event going.

The talk does, as you can see, cover a wide array of things that has to do with smooth streaming. And to make it even broader, I will show off the Rough Cut Editor (an open source rough video editing tool built in Silverlight). And it would of course not be complete with out touching the cloud. So to finish it off, I will show you how you can deliver smooth streaming media out of Azure blob storage. A very cost effective and good way to share your media.

So if you are in Wellington, or close by, feel free to drop by if it sounds interesting. More information is available here: http://www.dot.net.nz/UserGroupPages/WellingtonNET.aspx