Fancybox with Jquery and partial views

Recently I’ve been working on a site redesign and I thought a nice little feature would be to have a fancybox (read lightbox) and inside there provide some basic site statistics, current user count etc.

So the aim is to have a fancybox appear with it’s content loaded via ajax from a partial view on the server. The content will appear when a button is clicked on the page.

I’ll be using the following :

Partial View

public PartialViewResult p_popup()
   return PartialView();


$(document).ready(function() {
   $("#menuButton").click(function() {
      // Close the overall model
      // Open a fancybox
         url: '/fb/p_popup',
         type: 'POST',
         data: '',
         success: function (data) {

And that’s it, I prefer this method to using templates on the client side. In a follow up to this I’ll deal with posting back from forms with validation.

Javascript intellisense and VS2010

Sometimes you just take things for granted, I was helping a friend with some code and he was suddenly amazed to see that I was getting intellisense in visual studio. So I thought that I would share this little tip.

In visual studio open up a javascript file and from the solution explorer then drag another script file into the code editor.

That’s it job done!

WIF and load balancing with MVC 3.

Recently I’ve been getting to grips with WIF and the starter STS which I must say is an excellent starting point. A requirement for a project that I’ve been working on was to enable the site to run in a load balanced environment without any affinity to a particular node.

From the outset this seemed quite straight forward. After customizing the STS to use our own credential store and aligning the machine keys things looked to be rocking, well from an STS point of view.

After adding the STS reference and deploying the web application everything looked OK initially, looking in firebug I could see plenty of requests reporting “500” internal server error.

After much investigation it became clear that one of the nodes couldn’t access the token due to it being protected via DPAPI.

The following assumes that you have a serverCertificate inside the microsoft.identitymodel node in your config. It also assumes that you application pool has access to find the certificate in the local store.

Changes to the global.asax file.

New event handler

void onServiceConfigurationCreated(object sender, ServiceConfigurationCreatedEventArgs e)
List<CookieTransform> sessionTransforms = new List<CookieTransform>(new CookieTransform[]
new DeflateCookieTransform(),
new RsaEncryptionCookieTransform(e.ServiceConfiguration.ServiceCertificate),
new RsaSignatureCookieTransform(e.ServiceConfiguration.ServiceCertificate)

SessionSecurityTokenHandler sessionHandler = new SessionSecurityTokenHandler(sessionTransforms.AsReadOnly());

Changes to application start method.

protected void Application_Start()
FederatedAuthentication.ServiceConfigurationCreated += onServiceConfigurationCreated;

The preceding enabled tokens to be treated the same on all nodes in the cluster.