ASP.NET MVC Beta 1 - Does It Support Strongly Typed Data?

In previous releases, there were 3 ways to transfer data from the controller to view AFAIK (shown below).

I want to use method (2) with MVC Beta 1, but I cannot find the renderView method. So what is the new syntax (if it is still possible)? Thanks in advance.

Ben.

Syntax # 1: Old School Dictionary

ViewData["Name"] = "Moo-moo";
ViewData["Age"] = 6;
ViewData["HasFunnyFace"] = true;
RenderView("ShowCat");

SyntaxC # 2: Explicit ViewData p>

RenderView("ShowCat", new ShowCatViewData {
    Name = "Moo-moo",
    Age = 6,
    HasFunnyFace = true
});

SyntaxC # 3: Anonymously Typed Object

RenderView("ShowCat", new { 
    Name = "Moo-moo", 
    Age = 6, 
    HasFunnyFace = true 
});
+3
source share
2 answers

In beta 1, use the View method:

return View ("ShowCat", <TYPED_DATA_SET_OR_OTHER_MODEL>);

The View method has replaced the RenderView method.

+2
source

Kieron Visual Studio 2008 (, 2005/VSE?), " " .

, , .

+1

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


All Articles