Is it more efficient to locate the view directly in MVC?

I want the code to work as efficiently as possible. I have species that are located in places like:

~/Areas/Administration/Views/Accounts/Create.cshtml 

What I would like to know is someone looked in if it is more efficient to directly encode the location of the view in action as follows:

 return View("~/Areas/Administration/Views/Accounts/Create.cshtml", vm); 

If this is not the case, then I believe that he will first search for all of the following locations:

 ~/Areas/Administration/Views/Accounts/Create.aspx ~/Areas/Administration/Views/Accounts/Create.ascx ~/Areas/Administration/Views/Shared/Create.aspx ~/Areas/Administration/Views/Shared/Create.ascx ~/Views/Accounts/Create.aspx ~/Views/Accounts/Create.ascx ~/Views/Shared/Create.aspx ~/Views/Shared/Create.ascx ~/Areas/Administration/Views/Accounts/Create.cshtml 
+4
source share
2 answers

Donโ€™t worry about it and itโ€™s never hard at your viewing places like this. When working in Release mode, ASP.NET MVC caches these places and does not fulfill all these expensive searches.

+6
source

Sam Shaffron investigated the impact of performance on blog location. Two conclusions:

  • when you launch release builds, viewpoints are cached, so thereโ€™s actually no performance penalty
  • in debug mode, you can increase performance by removing support for view engines that you are not actually using (such as WebForms).

Therefore, I suggest Darina to assume that the location in hard coding mode will be simply inconvenient for you, and you will not get a performance advantage if you do the rest in the book.

+3
source

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


All Articles