Asp.net mvc 2.net 4.0 error when displaying a Tuple model type with more than 4 elements

When I create a strongly typed View in Asp.net mvc 2, .net 4.0 with the Tuple model type, I get an error when Tuple has more than 4 elements

Example 1: view type Tuple<string, string, string, string>(4-tuple) and everything works fine

View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<Tuple<string, string, string, string>>" %>

controller:

var tuple = Tuple.Create("a", "b", "c", "d");
return View(tuple);

example 2: view type Tuple<string, string, string, string, string>(5-tuple) and I have this error:Compiler Error Message: CS1003: Syntax error, '>' expected

View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<Tuple<string, string, string, string, string>>" %>

controller:

var tuple = Tuple.Create("a", "b", "c", "d", "e");
return View(tuple);

example 3 if my view model has a dynamic type, I can use both 4-tuple and 5-tuple, and on the page

no error.

View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

controller:

dynamic model = new ExpandoObject();
model.tuple = Tuple.Create("a", "b", "c", "d");
return View(model);

or

View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

controller:

dynamic model = new ExpandoObject();
model.tuple = Tuple.Create("a", "b", "c", "d", "e");
return View(model);

Even if I have something like a Tuple<string, Tuple<string, string, string>, string>3-tuple, and one of the elements is also a tuple, and the sum of the elements in all the tuples is more than 4, I get the same error, it Tuple<string, Tuple<string, string>, string>works fine

+3
1

: < Tuple < object1, object2 → ViewModel

< Tuple < object1, object2 → ViewModel

, 5 . ( ) , 5 ( ). , 5 . , 5 ( ASP MVC 2). , , . , , . , , , , . , , , - ... , . !

+1

Source: https://habr.com/ru/post/1742364/


All Articles