ASP.NET Core MVC Interview Question #170
What is application model customization in MVC?
Testing, AJAX/JavaScript Integration, Localization & Advanced MVC Senior Advanced
Quick Interview Answer
During startup, MVC builds an application model describing discovered controllers, actions, parameters, selectors, routes, and related metadata. Application model conventions can inspect or modify this model before endpoints are finalized.
Detailed Explanation
During startup, MVC builds an application model describing discovered controllers, actions, parameters, selectors, routes, and related metadata. Application model conventions can inspect or modify this model before endpoints are finalized.
This is an advanced extensibility point for organization-wide behavior such as route conventions. It should not be used when a simple route template or attribute expresses the requirement more clearly.
Code Example
public class MyApplicationModelConvention
: IApplicationModelConvention
{
public void Apply(ApplicationModel application)
{
foreach (var controller in application.Controllers)
{
// Apply a consistent convention.
}
}
}