Here are some more ASP.NET Core MVC interview questions:
Q1. What is view compilation in ASP.NET Core MVC and why is it useful?
A1. View compilation converts Razor views to C# classes during application startup. This avoids compilation overhead at runtime, improving response time. It is enabled by setting RazorCompileOnBuild to true.
Q2. How do you handle errors and exceptions in ASP.NET Core web APIs?
A2. Using middleware such as app.UseExceptionHandler() to catch errors and return consistent error responses. We can also use filters like [ApiExplorer] for handling errors at controller action level.
Q3. What is model validation in ASP.NET Core MVC?
A3. Validating model properties based on validation attributes like [Required], [MaxLength] etc. applied to the model class. Validation is automatically triggered and error messages displayed in views using ValidationSummary, ValidationFor helpers.
Q4. How do you implement localization in ASP.NET Core MVC application?
A4. By configuring localization services in Startup. We define resource files per culture, configure localization middleware, call CreateLocalizationConvention to specify resource file locations. Use IStringLocalizer to access localized strings.
Q5. What are the differences between .NET Core and .NET Framework Runtime?
A5. .NET Core is cross-platform, lightweight and supports more modern application scenarios like containers/microservices. .NET Framework supports older application models like WPF desktop apps, Windows workflows - limited to Windows.
Q6. What is middleware in ASP.NET Core and how does it work?
A6. Middleware are components that are part of the app pipeline that handle HTTP requests/responses. Multiple middleware are chained together using Use() in Configure() method. Pipeline flows through each middleware sequentially.
Q7. What are the main advantages of using ASP.NET Core over ASP.NET MVC?
A7. Cross-platform support, better performance, integration with modern client-side frameworks, lightweight and modular architecture due to middleware, configuration via C# code.