Skip to content

Xbox articles

Behind the scenes at – RSS enabling web marketplace  

A number of people were requesting additional RSS feeds for the web marketplace. (We had just one that included all new arrivals)

Looking across our site as the various lists of products we display today the significant views are:

  • Browse games by department
  • Search results
  • Promotions (e.g. Deal of the week)
  • Game detail (shows downloads available beneath it)
  • Avatar item browse

These views also have sorting options and a set of filters available for things like product type, game genre, content rating etc.

So we had a couple of options:

  1. Write controller actions that expose the results of specific queries as RSS
  2. Introduce a mechanism whereby any of our product result pages can render as RSS including any user-defined filtering

Our web marketplace is written in ASP.NET MVC (like most of so while option 1 sounds simpler MVC really helps us make option 2 more attractive by way of a useful feature called ActionFilters that let us jump in and reshape the way existing actions behave.


ActionFilters can be applied to either to an individual action method on a controller or to the controller class itself which applies it to all the actions on that controller. They provide hooks into the processing pipeline where you can jump in and perform additional processing.

The most interesting events are:

  • OnActionExecuting
  • OnActionExecuted
  • OnResultExecuting
  • OnResultExecuted
We’re going to hook in to the OnActionExecuted step – this is because we always want to run after the code in the controller action has executed but before the ActionResult has done it’s work – i.e. before page or RSS rendering.

Writing our ActionFilter

The first thing we want to do is identify that a request wants the RSS version. One way is to read the accepts header and switch when it requests mime/type but this can be a little trickier to test,  another is to append a query parameter on the url which is very easy to test.

Once we’ve identified the incoming request should be for RSS we need to identify the data we want to turn into RSS and repurpose it.

All the views we identified at the start of this post share a common rendering mechanism and each view model subclasses from one of our base models. For simplicity though we’ll imagine an interface that just exposes an IEnumerable<Product> property.

public class RssEnabledAttribute : ActionFilterAttribute {
  public override void OnActionExecuted(ActionExecutedContext filterContext) {
    var viewModel = filterContext.Controller.ViewData.Model as IProductResultViewModel;
    if (viewModel == null)

    var rssFeedTitle = FeedHelper.MakeTitle(viewModel.Results);
    filterContext.Controller.ViewData.Add("RssFeedTitle", rssFeedTitle);

    var format = filterContext.RequestContext.HttpContext.Request.QueryString["format"];
    if (format == "rss" && rssFeedTitle != null) {
      var urlHelper = new UrlHelper(filterContext.RequestContext);
      var url = QueryStringUtility.RemoveQueryStringParameter(filterContext.RequestContext.HttpContext.Request.Url.ToString(), "format");
      var feedItems = FeedHelper.GetSyndicationItems(viewModel.Results, urlHelper);
      filterContext.Result = FeedHelper.CreateProductFeed(rssFeedTitle, viewModel.Description, new Uri(url), feedItems);


This class relies on our FeedHelper class to achieve three things it needs:

  1. MakeTitle takes the request details – i.e. which page, type of products, filtering and sorting is selected and makes a title by re-using our breadcrumbs
  2. GetSyndicationItems takes the IEnumerable<Product> and turns it into IEnumerable<SyndicationItem> by way of a foreach projecting Product into SyndicationItem with some basic HTML formatting, combining the product image and setting the correct category (with a yield thrown in for good measure)
  3. CreateProductFeed then creates a Syndication feed with the appropriate Copyright and Language set and chooses the formatter – in our case RSS 2.0 but could easily be Atom 1.0, e.g.
public static SyndicationFeedResult CreateProductFeed(string title, string description, Uri link, IEnumerable<SyndicationItem> syndicationItems)
    var feed = new SyndicationFeed(title, description, link, syndicationItems) {
        Copyright = new TextSyndicationContent(String.Format(Resources.FeedCopyrightFormat, DateTime.Now.Year)),
        Language = CultureInfo.CurrentUICulture.Name

    return new FeedResult(new Rss20FeedFormatter(feed, false));

The FeedResult class is a simple one that takes the built-in .NET SyndicationFeed class and wires it up to MVC by implementing an ActionResult that writes the XML of the SyndicationFeedFormatter into the response as well as setting the application/rss+xml content type and encoding.

Advertising the feed in the head

Now that we have the ability to serve up RSS we need to let browsers know it exists.

The ActionFilter we wrote above needs to know the title of the RSS feed regardless of whether it is rendering the RSS (which needs a title) or rendering the page (which will need to advertise the RSS title) so it always calculates it and then puts it into the ViewData dictionary with the key RssFeedTitle.

Now finally our site’s master page can check for the existence of that key/value pair and advertise it out with a simple link tag:

var rssFeedTitle = ViewData["RssFeedTitle"] as string;
if (!String.IsNullOrEmpty(rssFeedTitle)) { %>
<link rel="alternate" type="application/rss+xml" title="<%:rssFeedTitle%>" href="<%:Url.ForThisAsRssFeed%>" />
<% }

This code requires just one more thing – a very small UrlHelper which will append “format=rss” to the query string (taking into account whether there existing query parameters or not).

The result of this is we can now just add [RssEnabled] in front of any controller or action to turn on RSS feeds for that portion of our marketplace! :)


Six great new features at  

It’s been quite a while since had a major update and today sees the launch of the new version with a clean new look and a whole host of new features that our teams here at LIVE engagement have been working on.

There are a whole great new set of features, my favorites are below… note that some of these are not available in non-LIVE locales.

Showing the Avatar Editor in action

1. Avatars

Avatars are no longer just for the console but are escaping out onto the web and Windows Phone 7. With the new Avatar Editor you can create your own avatar or modify your existing one with a new easy-to-use interface from your browser.

The new Avatar Marketplace lets you search and find cool items for your avatar to wear and try them on right-there in the search pages. Head on in either by game or by lifestyle (brands) (click the little grid icon to see sub-brands such as your own university’s sports team!).

Because these guys are 3D animated they require Silverlight to be installed on your machine (the streaming videos on also require it)

2. Marketplace search & results

A brand new search function means we get much better results than before, fuzzy matching and some dynamic filtering options that appear on the left-hand side letting you dig down into family friendly games (e.g. by game ratings).

Another cool use is to search for your favorite band and see what tracks and packs they have available. Then head to the game filter on the left to see only the ones that work with your game (e.g. Rock Band, Guitar Hero, Dance Central etc!)

When you visit the product detail page it now shows the images and streaming video inline (goodbye popups) as well as game add-ons showing which games they work with – useful for those music track packs!

3. Hand-picked promotions

Our content teams can now put together collections of themed hand-picked games, add-ons etc. that you can you filter, sort and explore from such as the new Kinect games (gone) or family-friendly fun (gone).

Gold and family gold members should keep an eye out for Gold exclusive offers or pricing!

4. Streamlined account creation

It’s now easier-than-ever to sign up for a free Xbox live account. Less questions, less steps and we’ll give you a randomly-generated gamertag you can change for free later when you’ve had chance to decide on the perfect name for your game-playing alter-ego. (We’ve seen some fun auto-generated ones during the development cycle including FirmJunk,

Comparing games on

5. Compare games with your friends

Okay, you could compare games before but the new UI is better and there’s a cool hidden feature that lets you compare against multiple people at the same time.

To do this head into My Xbox’s Game Center and choose a friend to compare with. Now, notice the url at the top of the page? Put a comma after it and another gamertag to see three… or another comma and a gamertag to see all four (the maximum) side-by-side.

6. Family center

New with this update is the Gold Family Pack (discontinued) which lets you get four gold subscriptions for $99 a year and lots of cool family features including play time reports, gifting points, allowances etc.

There are a whole host of extra features to be seen at including mobile-to-web gaming, improved messaging, simplified UI etc. so go check them out!