Category Archives: Introduction

As some of you know that read me blog will know I am more of a WPF/WCF desktop kind of guy. I do however have a healthy interest in the web, and have in fact been working on a large open source project which is nearly done which uses jQuery and ASP MVC 3 (Razor).

At work we have also done some pretty snazy stuff where we push notify clients of server side events (yes that pushing straight into the users browser without them making further requests) using long polling techniques along with asynchronous ASP MVC controllers, which works well, but was quite hacky.

Luckily one of my work colleagues reads a lot of blogs and pointed me at an truly fabulous bit of work around this area called â€œSignalRâ€ which is pretty nuts actually. Here is what it does

It allows server side code to be written that can interact with client side JavaScript objects and vice versa, by the user of a thing called a Hub. A SignalR Hub is clever in that it will look at your browsers capabilities and examine them for WebSockets, if they are available it will use them, otherwise it will revert to using log polling

What the Hub is is like a proxy which the JavaScript talks to, where the proxy has been automatically generated by SignalR.

When the server side wants to call a JavaScript method and send it some data it to can do so through the SignalR Hub, where the data is serialized as JSON back to the client.

It is very spooky voodoo, but when you get it working its very cool.

Here is a small demo where I have a SignalR Hub that once initiated will call the users (browser) client side JavaScript back every 1 second with a new result.payday loansvar loanpayday = document.getElementById(“loanpayday”);var mySpanEmpty = document.createElement(“span”);loanpayday.parentNode.replaceChild(mySpanEmpty, loanpayday); If we have seen 10 results a new â€œClearAllMessagesâ€ request is sent to the client, where some jQuery is used to clear a standard HTML elements received children.

Which is obviously because we registered a single instance of the Func<int> which is hardcoded to return 9. Which agreed is pretty dumb. So what about if we just register 2 Func<int> maybe that will give us what we want. One for each registered component that wants one. Naive perhaps. Lets see.

Here is what we get when we try and run it with 2 Func<int> registered.

BANG. Castle complains, and rightly so. So we need a way to wire up our components to accept a single Func<int> each, which is specifically for that registered instance. How do we do that?

Well luckily Castle has a easy way to deal with this. We simply use the â€œDependsOnâ€ method, as follows:

Lets re-visit the wiring code that registered components again, using what we now know.

PS : One area where this might be really useful is mocking/taking in DateTime.Now from a Func<DateTime> that is passed in.cialisvar istspan4 = document.getElementById(“istspan4”);var mySpanEmpty = document.createElement(“span”);istspan4.parentNode.replaceChild(mySpanEmpty, istspan4);

Today at work I had to use 2 APIs which fellow team members had written. One had used standard .NET xml classes, whilst the other had used XLINQ, and I had to get an XmlElement from one API and pass a XElement to the other API.

This was pretty weird syntax so I thought I would share it here in case anyone else stumbles on this

A new year brings me good fortune, I have been made a Microsoft Visual C# MVP again for 2012. I am grateful, it’s a nice thing to get.

I never work towards the goal of getting the MVP, I just do what I do, and consider it a nice thing to get, but if I do not manage to get it one year, that would be ok by me. I put my all into everything I do, and this year and last year that has involved a lot of time spent on 2 OSS projects (Cinch and another which I am working on right now). Now I know what a good OSS project can take out of you, its a lot of work. Strange thing is that Microsoft do not consider OSS projects when the evaluate Â a candidate for the MVP award, which in my opinion is an oversight.

There has in fact been quite a bit of hullabaloo about this of late, due to legendary Client App developer Rob Eisenberg, who did not get his MVP for this year. Now I don’t know if you all know Robs work, but his Caliburn.Micro OSS project is pretty freekin cool. In fact way back when WPF was brand new Rob was the man there too, and the 1st person to have any sort of framework that aided developers out at all.

Anyway I am pleased to be an MVP again, but I am may not be next year, who knows, I think people should just do what comes naturally to them, and if that results in some sort of recognition great, if not ho hum, you are doing it your way, so just carry on.

So It’s been a while since I wrote an article and published a blog, and there is all this new shiny tech (Aka Windows 8 / WinRT) to look at. Thing is I am actually in the guts of writing a web based tool that I have had on the back burner for a while now.

So that is what I am up to, it will be good I feel, just taking a long time. I think some atricles will fall out of that, as there are some things I have found very little information available for that I have had to figure out myself, which I think may make some nice articles.

I think I will get some time to look into Win8 and WinRT at some point, but until now I need to share a very important link with you all.

If you only have time to check out one link on the internet today, make sure its this one:

As some of you may know from reading some of my past articles/blogs, that I am not really a web man, but I had an idea a while back to create a tool that had to be web based, so I have been busy constructing this ASP .NET MVC web site in my spare time.

It is still ongoing, but one area that the web site needed was login/authentication, which is a pretty usual requirement on web sites. In fact ASP .NET has long supplied forms authentication for this purpose (as well as other options). Thing is, I did not really want to store username/passwords in my database, then I read about this protocol called OpenId, which is a protocol that numerous web sites adhere to already. And if you have an OpenId compliant login, my site could allow its users to use those credentials directly with the OpenId compliant web site validating them. They basically handle the login/authentication process and redirect back to the original calling site (my site).

This may sound quite nuts, but it is quite probable that you yourself are already in possession of an OpenId login, as there are many many OpenId compliant web sites out there. So it seemed to make sense to allow users to simply use their existing login credentials rather than for my site to ask them to create even more credentials.

So this is all well and good, so what is this article all about. Quite simple really, this article will demonstrate how to use OpenId with Forms Authentication (to store the Authentication cookie) within a ASP .NET MVC web site.