I'm not a fan of the codebehind and designer files that are generated when you create a new ViewPage. I like a clean solution and for me that means view files (.aspx) that don't have plusses next to them (see the photo to the right and compare the Home and Login folders).
If you want to use strongly typed view data and you don't want to add the codebehind and designer files for the measly few characters you have to type to make a view strongly typed:
1: public partial class Index : ViewPage<LoginData>
In this particular case I have to add two extra files to source control solely for the purpose of having "<LoginData>"...seems like a waste.
If you want to do the same thing without the extra overhead of two files, simply use CLR notation. The old inherits attribute:
1: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
3: Inherits="ABCCompany.MVC.Web.Views.Home.Index" %>
1: <%@ Page Language="C#"
3: Inherits="System.Web.Mvc.ViewPage`1[[ABCCompany.MVC.Web.Models.LoginData, ABCCompany.MVC.Web]]" %>
Not the prettiest code I've ever seen, but it gets the job done without extra (needless) files.
08-13-2008 3:19 PM