View Search Path Convention and Logging
Explore how ASP.NET Core MVC uses view search path conventions to locate Razor views for different controller actions. Learn to trace view resolution by adjusting file names and understand the default search locations including shared folders. Also, discover how to implement logging using the dependency injection service to write messages to the console for debugging. This lesson helps you understand key conventions and logging techniques to build and troubleshoot MVC web applications efficiently.
We'll cover the following...
The view search path convention
The Index and Privacy methods are identical in implementation, yet they return different web pages. This is because of conventions. The call to the View method looks in different paths for the Razor file to generate the web page. Let’s deliberately break one of the page names so that we can see the paths searched by default:
Step 1: In the Northwind.Mvc project, expand the Views folder and then the Home ...