Different ways to initialize a model for presentation in ASP.NET MVC

How much does the actual memory / performance increase in an ASP.NET MVC controller cost when using these two different ways to declare a model for presentation?

User user = userService.GetByID(id);
return View(user);

or

return View(userService.GetById(id));

I assume that the last one is more efficient since we are not initializing the object, however the first one is more readable. Will it make a difference on a web server with thousands of visitors?

+3
source share
2 answers

; , : 1) ( , ); 2) ( ), ( ) .

, .

, , user; , , , , .

+4

, , . , : -)

+4

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


All Articles