Monday, February 22, 2010

Code: The type 'int' must be a reference type in order to use it as parameter

I received a new error message developing and ASP.Net MVC page today:

The type 'int' must be a reference type in order to use it as parameter 'TModel' in the generic type or method 'System.Web.Mvc.ViewPage<TModel>'. 

Apparently MVC requires a reference type to use the constructor that accepts a type as a parameter.  I was trying to pass an int as the Model type.  The workaround was pretty simple, I just used ViewData and a generic MVC page (Inherits="System.Web.Mvc.ViewPage").