Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it more efficient to specify the view location directly in MVC?

I want to have code that runs as efficiently as possible. I have views that are located in locations such as:

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

What I would like to know is has anyone looked into if it is more efficient to directly code the view location in action like this:

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

If not coded like this then I believe it would search all the following locations first:

~/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
like image 814
Samantha J T Star Avatar asked Jan 18 '23 02:01

Samantha J T Star


1 Answers

Don't worry about this and never hardcode your view locations like this. When running in Release mode ASP.NET MVC keeps those locations cached and it doesn't perform all those expensive lookups.

like image 76
Darin Dimitrov Avatar answered Jan 21 '23 17:01

Darin Dimitrov