Time for a new design? I think so!

Probably some people already saw my new blog design go live yesterday.

Less than a year ago I upgraded from Wordpress 2.2.1 to 2.6. Now I just wanted a new design. And for the sake of doing some HTML and CSS I made my own design. I must say I really like it myself.

The Past – Dreamplace by Sabiostar

image

The Present – Blue Mozaik by Mark Monster

image

What are the most awesome features?

image Yes most of the things are just visible, that’s why it’s called a design. But I must say I really like the 3D-Tag cloud, originally made by Peter Gerritsen. But a few enhancements. Like getting the tags as an initParam and limiting the amount of tags shown. Besides that I also track the clicks in the tag cloud inside Google Analytics as events.

Further on I made use of jquery to add some nice small features where I need to manipulate the HTML-Dom. For example the comment-form shows your Gravatar while you’re just typing your response. The Gravatar API is very easy, just make sure you MD5-Hash the e-mail address and and add this to a specific url for basic support of Gravatar. For full API please visit their site.

 

 

 

 

If you find some things that can be done better, please let me know. I already fixed a small bug in the comment form this morning. And of course please let me know all the positive things you have to say about my blog.

I made it very clear that I’m blogging about .NET and Silverlight most of the time. This even though my blog is still kept alive by Wordpress, built in php.

Moonlight Preview 3, a new Test Run.

Moonlight has a new update. Basically I even missed the second preview. But here the test run of preview 3. The release notes are available here.

I just had to search for updates on my add-ons. Just updated it like any other Firefox add on. And a restart of the browser was all that was needed.

image

Just giving it the same new try as before.

Of course I start with testing the Silverlight.net site. Does it still work? Yes it does, it even feels a little better. Faster response. But looks are the same, so no new screenshot.

Next is the Silverlight Toolkit Example page for Silverlight 2. Ah my first surprise. It runs, but let’s look at the charts, the browser stops responding.

image

What about the Silverlight Toolkit examples for Silverlight 3? Still crashes my dear browser.

image

What about the performance of the Hard Rock deep-zoom site? Yes it feels like it’s better, but I didn’t measure it. But while clicking around a little bit I got this screen and error.

image 

Hmm something else that is interesting to test is the 3D Tag Cloud by Peter Gerritsen will it run? And yes it runs! Interesting.

image

Hmm, in the end it still not enough for pre-production. But it performs better, at least it feels like it.

Ps. This article is cross posted on: Mark Monster’s blog and Silverlight Help.

Advertisement?

Yes this is kind of an advertisement, but I might end up with a set of licenses. That's why. Unit Testing ASP.NET? ASP.NET unit testing has never been this easy. Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers. The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price. Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit. The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement. Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends. Go ahead, click the following link for more information on how to get your free license.

Silverlight 3 and RIA Service – Cross Domain Proxy Enhanced

Some time ago I wrote a very small RIA Service that could be used to overcome Cross Domain issues. It’s a proxy that sits between your Silverlight application and any server where you want to get content over http.

A lot people know that not even half of the public API’s have cross domain configurations in place. The best solution that’s left is a proxy that can forward the calls to the public API and return the response back to the original caller. This article will expand the Silverlight part of the Cross Domain Proxy. Nothing needs to be changed to the RIA Service part of this Cross Domain Proxy.

What is the problem we have with the solution from my earlier article about Cross Domain Proxy?

One thing: The Cross Domain Proxy RIA Service is a generic service that can be used for all cross domain accesses. So basically we could write an application that’s performing multiple calls through the cross domain proxy at the same time. But how do we use the responses? We basically have one event “ProcessCompleted”, should we then react to this event by doing different things? Yes that could be, but we could do it differently as well.

I’m thinking about a ProxyService that’s running on Silverlight which has a little bit more knowledge compared to the RIA Services generated stub. This service would enable to do a cross domain request but provide a function to be called on completion at the same time.

The code using this service would look like this (firing multiple cross domain requests at the same time):

var domainProxyService = new DomainProxyService();
domainProxyService.Process(
    new ProxyRequest
        {
            Url = "http://www.silverlight.net/"
        },
    response => Debug.WriteLine(string.Format("1:", response.Content)));
domainProxyService.Process(
    new ProxyRequest
        {
            Url = "http://www.asp.net/"
        },
    response => Debug.WriteLine(string.Format("2:", response.Content)));

domainProxyService.Process(
    new ProxyRequest
        {
            Url = "http://www.azure.net/"
        },
    response => Debug.WriteLine(string.Format("3:", response.Content)));

The DomainProxyService needs to be intelligent enough to be able to route the reponses to the correct function pointers.

So there needs to be a key that can help associate the request with the response. In my last article I introduced the property Id in the ProxyRequest and the RequestId in the ProxyResponse. But for all purpose I don’t want to put a value in the Id, as a caller I don’t use this field, it’s just for internal usage so that association between Request and Response is possible.

My idea is to put a dictionary in the DomainProxyService to associate the request id with a function pointer. I want the function point to be of a type void that accepts one parameter of type ProxyResponse. That would make a dictionary like this:

private readonly Dictionary<Guid, Action<ProxyResponse>> m_dictionaryOfListeners =
    new Dictionary<Guid, Action<ProxyResponse>>();

The method to process a request isn’t that difficult. It will generate a new Id if it’s still empty. Besides that it will add an item to the dictionary, the key with the associated function to call on completion. And after all the most important part, we will call the original RIA Service.

public void Process(ProxyRequest proxyRequest, Action<ProxyResponse> callBack)
{
    //Generate a unique id if it doesn't contain an id yet.
    if (Guid.Empty == proxyRequest.Id)
        proxyRequest.Id = Guid.NewGuid();
    //Add the callback to list of listeners for use on completion.
    m_dictionaryOfListeners.Add(proxyRequest.Id, callBack);

    m_domainProxy.Process(proxyRequest);
}

We will still need to have one generic listener for the ProcessCompleted event. This listener will look up the appropriate function to call in the dictionary. Will invoke the function and remove the item in the dictionary.

private void DomainProxyProcessCompleted(object sender, InvokeEventArgs e)
{
    var proxyResponse = e.ReturnValue as ProxyResponse;
    if (proxyResponse != null)
    {
        //If the dictionary contains listeners for this request
        if (m_dictionaryOfListeners.ContainsKey(proxyResponse.RequestId))
        {
            m_dictionaryOfListeners[proxyResponse.RequestId].Invoke(proxyResponse);
            m_dictionaryOfListeners.Remove(proxyResponse.RequestId);
        }
    }
}

To be complete here the full source of the DomainProxyService class. Please remember this article continues on my previous article about Domain Proxy.

public class DomainProxyService
{
    private readonly Dictionary<Guid, Action<ProxyResponse>> m_dictionaryOfListeners =
        new Dictionary<Guid, Action<ProxyResponse>>();

    private readonly DomainProxy m_domainProxy = new DomainProxy();

    public DomainProxyService()
    {
        m_domainProxy.ProcessCompleted += DomainProxyProcessCompleted;
    }

    private void DomainProxyProcessCompleted(object sender, InvokeEventArgs e)
    {
        var proxyResponse = e.ReturnValue as ProxyResponse;
        if (proxyResponse != null)
        {
            //If the dictionary contains listeners for this request
            if (m_dictionaryOfListeners.ContainsKey(proxyResponse.RequestId))
            {
                m_dictionaryOfListeners[proxyResponse.RequestId].Invoke(proxyResponse);
                m_dictionaryOfListeners.Remove(proxyResponse.RequestId);
            }
        }
    }

    public void Process(ProxyRequest proxyRequest, Action<ProxyResponse> callBack)
    {
        //Generate a unique id if it doesn't contain an id yet.
        if (Guid.Empty == proxyRequest.Id)
            proxyRequest.Id = Guid.NewGuid();
        //Add the callback to list of listeners for use on completion.
        m_dictionaryOfListeners.Add(proxyRequest.Id, callBack);

        m_domainProxy.Process(proxyRequest);
    }
}


Ps. This article is cross posted on:
Mark Monster’s blog and Silverlight Help.

Silverlight using WCF with Windows Authentication

We all know it’s not possible yet to provide credentials when calling WCF Service. I’m telling yet, because I saw some signs that we might get support for credentials.

But what about now? Yes now, because Silverlight 3 isn’t release to the web yet.

Let’s think of all those applications that are running in the Intranet Zone for example. If they are built on the .NET environment, they often make use of Windows Authentication to authenticate the user. And after that make use of the roles assigned to the user to authorize the user.

But when we are working in the Silverlight environment we don’t really have the ability to make use of the User that’s already authentication against the Active Directory. But what about the services that Silverlight is using? Well that’s basically what this article is about.

Windows Authentication on WCF

A few days ago I read an article about Windows Authentication on WCF. This article explains the different steps to get Windows Authentication on WCF very well. But for the sake of this article I will summarize the steps that are required.

  1. Create your WCF Service
  2. Ensure authentication mode is Windows by adding <authentication mode="Windows" /> to the web.config
  3. Create the binding in the system.servicemodel element of the web.config just like this.
    <bindings> 
      <basicHttpBinding> 
        <binding name="BasicHttpEndpointBinding"> 
          <security mode="TransportCredentialOnly"> 
            <transport clientCredentialType="Windows" /> 
          </security> 
        </binding> 
      </basicHttpBinding> 
    </bindings>
  4. Make sure the WCF service configuration makes use of the binding created in step 3 by adding the following to the endpoint element for your WCF service.
  5. <endpoint … bindingConfiguration="BasicHttpEndpointBinding" />
  6. The article mentions to disable anonymous access and enable Windows Authentcation. But to make it work on Windows Server 2008 I had to make sure anonymous access was enabled as well.
    image
  7. If you want authentication to be automated you can do this easily by adding the url of your service to the local intranet zone.
  8. Just add a service reference like you would normally do from Silverlight.
  9. Create a very simple method to know if it’s working as expected. Something like:
    [OperationContract] 
    public string Hello() 
    { 
        // Add your operation implementation here 
        return string.Format("Hello, {0} at {1}", HttpContext.Current.User.Identity.Name, DateTime.Now); 
    }

And yes that just works. And this enables more things as well like ask if the user is in a specific role. Basically all the things you’re used to have access to in a Windows Authenticated ASP.NET application are available.

I think at least part of the credits for this article should go to Shivprasad koirala who wrote the Code Project article I refer to.

Let’s hope the next version of Silverlight enables credentials so we can make use of different authentication scenario’s as well.

Ps. This article is cross posted on: Mark Monster’s blog and Silverlight Help.