views:

92

answers:

1

I am working on a Facebook tab application. I am using asp.net MVC 2 with the "official" Microsoft Facebook SDK.

Most of my views are working just fine.

However, I have one that is causing a huge mess. I am simply returning a List<Tags> to the view and as my ViewModel. This problematic view is simply displaying the list in a foreach loop. Whenever navigate to this view I get a "System.Web.HttpException: Invalid Model" exception.

The most puzzling part of all this is that the same code is running without fail on our regular(non-Facebook) app that works just fine with the same code.

Any insight into why Facebook and asp.net MVC 2 would be causing this behavior would be much appreciated.

A: 

So, I finally figured out what was causing this dang problem.

It turned out to not be related to the View Model, the View or even the Action.

We are using another library. It is the Rest For Asp.NET MVC SDK. This library lets you decorate your action with [WebApiEnabled]. This allows those actions to return JSON or XML if the request has a ?format=json or ?format=xml.

If all of the actions in the controller should be Rest enabled then you can decorate the class instead of each method. Well this is what we did. And it was causing issues with the way that facebook grabs data.

So we moved the decoration from the class to the actions and the error went away.

zznq