giovedì 29 gennaio 2015

Asp.Net WebApi 2 and Enum

By default, Web API serializes ENUM data types to the numeric value but humans don't like code, we prefer string description.

So we need to add a Media Type Formatter. In Web API, the media type determines how to serialize the data with a built-in support for JSON, XML and form-urlencoded.

 The following helper method handles the configuration of the media formatter setting. This code should be added in the global.asax.cs file.

using Newtonsoft.Json;

protected void Application_Start()

void SerializeSettings(HttpConfiguration config)
   JsonSerializerSettings jsonSetting = new JsonSerializerSettings();
   jsonSetting.Converters.Add(new Converters.StringEnumConverter());
   config.Formatters.JsonFormatter.SerializerSettings = jsonSetting;

venerdì 2 gennaio 2015

Tool for testing website performance

8% of potential buyers cite extremely slow loading web pages as primary reason for abadoning their purchase. It does not seem a big number but for Amazon or other big ones it means milions of dollar.

I found some tools for testing the sites that I develop.

Pingdom Tools
Web Page Analyzer
Pagespeed Insights

In light of the fact that page weight is increasing every year, I hope this post will give you enough ammunition to be better prepared to tackle the performance challenge on your own projects.