Using KnockoutJS with SignalR in ASP.NET MVC

KnockoutJS is a MVVM implementation for JavaScript written by Steve Sanderson, in my opinion the author of the best ASP.NET MVC textbooks available. Simply put it lets you bind a JavaScript object model to your HTML UI using a Read more

A MongoDB Tutorial using C# and ASP.NET MVC

In this post I'm going to create a simple ASP.NET MVC website for a simple blog that uses MongoDB and the offical 10gen C# driver. MongoDB is no NOSQL database that stores information as Binary JSON (BSON) in documents. I Read more

Linq To SQL Tutorial

Check out some of my other Linq to SQL posts: EntityBase Inheritance Modifiers with SQLMetal Linq to SQL with WCF Services Linq to SQL Framework (Repository/Business wrapper) ObjectDataSource binding with server side paging and sorting Load Options Generic Framework using reflection This is a basic tutorial for Read more

WCF Services and Silverlight

Posted on by Joe in Silverlight, WCF | Leave a comment

After looking at WPF the other week I thought being a web developer it would be beneficial to look at Silverlight.  One of the first things I was interested to try was to access the server’s file system from the Silverlight application. I quickly found out that this wasn’t possible so I decided to create a WCF service hosted in the web application running my Silverlight application to access the file system for me.

To use a WCF service in Silverlight it must use basicHttpBinding. In Visual Studio you can add a ‘Silverlight-enabled WCF Service’ from the Silverlight category which creates a service using basicHttpBinding as default.

I created a simple service method called GetDirectories which returns an array of directory names within a given location.

 

public string[] GetDirectories()
{
    string path =  ConfigurationManager.AppSettings["GalleryDir"];
    IList<string> directories = new List<string>();

    foreach (string directory in Directory.GetDirectories(path))
        directories.Add(directory);

    return directories.ToArray();
}

After adding my service reference and creating an instance of my proxy I noticed that it did not contain the method GetDirectories. Instead I have GetDirectoriesAsync and an event called GetDirectoriesCompleted. This is cool as all service calls with Silverlight are asynchronous.

 

public Directories()
{
    InitializeComponent();

    GalleryContractClient proxy = new GalleryContractClient();
    proxy.GetDirectoriesCompleted += new EventHandler<getDirectoriesCompletedEventArgs>(proxy_GetDirectoriesCompleted);
    proxy.GetDirectoriesAsync();
}

void proxy_GetDirectoriesCompleted(object sender, GetDirectoriesCompletedEventArgs e)
{
    foreach (string directory in e.Result)
        tvDirectories.Items.Add(directory);
}

The Result property of GetDirectoriesCompleteEventArgs has the response from the request.

WPF Community Workshop – Sydney

Posted on by Joe in Personal | Leave a comment

Last weekend (23rd May) I attended the WPF Community Workshop in Sydney put on by Microsoft and run by a colleague of mine, Deepak Kapoor.

I had never looked into WPF as I am predominantly an ASP.NET developer although I did use Windows Forms for several years. I thought this would be a good opportunity to see what WPF was all about and I was impressed.

The workshop featured several labs which quickly taught the basics of WPF and XAML and went on to data binding.

We also looked at Expression Blendwhich is written with WPF. I really liked how easy it was to change the appearance of the standard controls and make them look however you want.

Will definitely be looking further into WPF in the near future…

The beast that is WCF

Posted on by Joe in WCF | Leave a comment

After spending nearly 3 years working some time ago on an application utilising Web Services with .NET 2.0 I thought it was about time I learned about WCF. I am currently reading the book Learning WCF by Michele Leroux Bustamante which so far has done a really good job describing the concepts of WCF, also including some good labs. WCF seems pretty powerful, but as the title of this post suggests, is quite a beast!

Blog me up

Posted on by Joe in Personal | Leave a comment

Over the time I’ve been using Microsoft .NET technologies I’ve often come across something I’ve done where I’ve thought, “If I had a blog I’d write a post about this”. I never got around to it before but after speaking with a guy at work I decided it was a good idea to start one. The only problem now is thinking of stuff to put on it…