C# 元组和类型化视图的Bug?
如果我使用定义视图,则视图存在werid问题C# 元组和类型化视图的Bug?,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,如果我使用定义视图,则视图存在werid问题 Inherits="System.Web.Mvc.ViewPage<List<Tuple<string, DateTime?, double?, double?, double?>>>" Inherits=“System.Web.Mvc.ViewPage” 我得到了werid错误: CS1003: Syntax error, '>' expected Line 118: public class v
Inherits="System.Web.Mvc.ViewPage<List<Tuple<string, DateTime?, double?, double?, double?>>>"
Inherits=“System.Web.Mvc.ViewPage”
我得到了werid错误:
CS1003: Syntax error, '>' expected
Line 118: public class views_report_intrestcalc_aspx : System.Web.Mvc.ViewPage<List<Tuple<string, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
CS1003:语法错误,应为'>'
第118行:public class views\u report\u intrestcalc\u aspx:System.Web.Mvc.ViewPage虽然我不知道为什么您的代码不编译(看起来很正确),而不是使用元组
,但我强烈建议您使用视图模型(甚至可能编译器也会因为丑陋而窒息:-):
Inherits=“System.Web.Mvc.ViewPage”
具有:
<%: Model.Username %>
<%: Model.Date %>
的可读性远远高于:
<%: Model.Item1 %>
<%: Model.Item2 %>
是的,ASP.NET编译器为您的示例生成的代码已损坏。我可以重新创建此文件(Visual Studio 2010、.NET 4、ASP.NET MVC 2)并获得:
public class views\u home\u index\u aspx:System.Web.Mvc.ViewPage
<%: Model.Item1 %>
<%: Model.Item2 %>
public class views_home_index_aspx : System.Web.Mvc.ViewPage<List<Tuple<string,
System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
private static bool @__initialized;
...
public class views_home_index_aspx : System.Web.Mvc.ViewPage<List<Tuple<string,
DateTime?, double?, double?, double?>>>,
System.Web.SessionState.IRequiresSessionState,
System.Web.IHttpHandler {
private static bool @__initialized;
...