ASP.NET Web API OData – Support Composite Key

The default EntitySetController doesn’t support composite keys. So if you have composite key models, you need some additional work. Here is an example about how to do that.The model is simple: public class Person{    [Key]    public string FirstName { get; set; }    [Key]    public string LastName { get; set; }    public int Age { get;…


Loop Reference handling in Web API

The Issue It’s very common to have circular reference in models. For example, the following models shows a bidirection navigation property: 1: public class Category 2: { 3: public Category() 4: { 5: Products = new Collection<Product>(); 6: } 7: 8: public int Id { get; set; } 9: public string Name { get; set;…


Support $format in ASP.NET Web Api

OData protocal defines $format to support different format: User can use following URL to change the return format to json instead of setting Accept header: http://localhost/api/Values?$format=json However, QueryableAttribute in Web Api OData package doesn’t support $format. ASP.NET Web Api provides such extensibility that you can change the default content negotiation by adding mappings to…


Single Page Application with Backbone.js and ASP.NET Web API

Spa is quite hot right now. There are many client choices. The reason why I chose backbone.js is because it supports connecting to a json web api. I am building an app on top of ASP.NET web api so I want to see how easy to make them work together. I won’t talk about too…


Using Razor Template Engine in Web API Self Host Application

[Update 8/15/2012] Update sample to Web API RTM packages As Web API is released with ASP.NET MVC 4 beta, it can be used in both web host and self host. You can view a sample code for self host here. When writing self host app, you may probably want to use template engine to show…


AutoF5 1.3 Published: Support Dynamically Loading CSS files

If you are first time here, please read my previous post:  Thanks for Scott Galloway’s suggestion. AutoF5 1.3 now supports to refresh CSS file dynamically by javascript instead of reloading the whole page. With this feature, It will be very convenient to develop and style Ajax UI.  In this update, I shamelessly copy the js snippet from and fixed…


Introducing to AutoF5 Nuget Package: Live Editing in ASP.NET

The problem: It is always annoying to switch between Visual Studio and browser back and forth when implementing a simple UI change. Especially editing an MVC project, there is no designer at all. Imagine that you want to adjust the size of an image, you have to do this: 1. Edit in CSS file 2….


Enable TFS Trace

Enable Component Trace in TFS AT How to: Use Web Services to Enable and Configure Trace for Team Foundation Server Components Enable Globally Trace in TFS AT 1. Open web.config file in C:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Web Services 2. Enable traceWriter to write to file: <add key=”traceWriter” value=”true”/> 3. Change the trace switches to <system.diagnostics>…