Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Tag Helpers: Use HTML-like syntax. Easier to read/maintain. <form asp-controller="Home" asp-action="Login"></form> HTML Helpers: C# methods used in Razor. @Html.BeginForm(&qu…
Short answer: ta cross requests No Preserved for 1 redirect only Real-world example (ShopNest) ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bu…
Short answer: Purpose ViewDa ta Current request No Pass data to views ViewBa Current request Yes ViewData wrapper (dynamic) TempD ata Across requests No Preserved for 1 redirect only Real-world example (ShopNest) ShopNes…
Short answer: Automatically maps form values, query strings, route data to C# model properties. public IActionResult Submit(User user) { ... } Binds complex types and simple types out-of-the-box. Real-world example (Shop…
Short answer: Decorate model properties: public class User { [Required] [EmailAddress] public string Email { get; set; } } Automatically validated during model binding. Use ModelState.IsValid to check. Example code Decor…
Short answer: IValidatableObject: public IEnumerable<ValidationResult> Validate(ValidationContext context) Custom Attribute: public class MyCustomAttribute : ValidationAttribute { Example code public override bool…
Short answer: Layouts: Shared structure (e.g. header, footer) using _Layout.cshtml. Partial Views: Reusable UI snippets (_LoginPartial.cshtml). View Components: Partial views with logic. public class CartViewComponent :…
Short answer: Via ViewBag / ViewData / Model: return View(model); // Strongly typed ViewBag.Message = "Hello"; ViewData["Count"] = 5; Example code Via ViewBag / ViewData / Model: return View(model); /…
Short answer: ActionFilter: Runs before/after action method. ResultFilter: Runs before/after view result. ExceptionFilter: Catches unhandled exceptions. Apply globally or via attributes. public class LogActionFilter : IA…
Short answer: Razor Pages use handler methods: public class IndexModel : PageModel { Example code public void OnGet() { ... } public IActionResult OnPost() { ... } } You can use asp-page-handler="Update" for cu…
Short answer: Inject services into PageModel constructor: public IndexModel(IMyService service) { ... } Also available in Razor views via @inject: @inject ILogger<MyPage> Logger Real-world example (ShopNest) ShopNe…
Short answer: Reusable libraries that contain Razor views, pages, static files, etc. Share UI components across multiple projects. dotnet new razorclasslib Real-world example (ShopNest) A ShopNest checkout request flows…
Short answer: Used to organize large applications into sections (e.g., Admin, Customer). Each Area has its own Controllers/Views/Models. [Area("Admin")] public class DashboardController : Controller { ... } Say…
Short answer: Handled via: ASP.NET Core Middleware WebOptimizer, Gulp, or Webpack Static files in wwwroot/ Enable in Startup.cs: app.UseStaticFiles(); Example code Handled via: ASP.NET Core Middleware WebOptimizer, Gulp,…
Short answer: ASP.NET Core supports Razor by default. You can add support for custom view engines by implementing IViewEngine. Real-world example (ShopNest) A ShopNest checkout request flows through middleware, hits a mi…
Short answer: Use IStringLocalizer<T> or IViewLocalizer: @inject IViewLocalizer Localizer <h1>@Localizer["Welcome"]</h1> Add resource .resx files for each language. Real-world example (ShopNes…
Short answer: Performance: Very similar, both use Razor rendering. Simplicity: Razor Pages have less boilerplate for page-based UIs. Maintainability: Razor Pages better for small apps, MVC better for large, modular apps.…
Short answer: REST (Representational State Transfer) is an architectural style for building scalable web services. RESTful APIs follow standard HTTP methods (GET, POST, PUT, DELETE) and stateless communication. Real-worl…
Short answer: SP.NET Core. ✅ Benefits: Automatic model validation Infer [FromBody] / [FromQuery], etc. 400 BadRequest returned automatically if model state is invalid. Improved parameter binding behavior Real-world examp…
Short answer: The [ApiController] attribute is used to denote Web API controllers in ASP.NET Core. ✅ Benefits: Automatic model validation Infer [FromBody] / [FromQuery], etc. 400 BadRequest returned automatically if mode…
Short answer: templates) Attribute Routing (Preferred): [Route("api/products")] [ApiController] public class ProductsController : ControllerBase { [HttpGet("{id}")] public IActionResult Get(int id) {…
Short answer: pplication/vnd.company.v1+json services.AddApiVersioning(options => { options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0…
Short answer: media type versioning) Use Microsoft.AspNetCore.Mvc.Versioning package. ✅ Supported methods: URL versioning: /api/v1/products Header versioning: X-API-Version: 1.0 Media Type versioning: Accept: application…
Short answer: ASP.NET Core selects the response format based on the Accept header. JSON is the default. To add XML: services.AddControllers() .AddXmlSerializerFormatters(); Accept: application/xml Real-world example (Sho…
Short answer: SP.NET Core infers the source when possible. Real-world example (ShopNest) ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs. Sa…
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Tag Helpers: Use HTML-like syntax. Easier to read/maintain. <form asp-controller="Home" asp-action="Login"></form> HTML Helpers: C# methods used in Razor. @Html.BeginForm("Login", "Home") ✅ Prefer Tag Helpers in modern ASP.NET Core apps.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: ta cross requests No Preserved for 1 redirect only
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Purpose ViewDa ta Current request No Pass data to views ViewBa Current request Yes ViewData wrapper (dynamic) TempD ata Across requests No Preserved for 1 redirect only
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Automatically maps form values, query strings, route data to C# model properties. public IActionResult Submit(User user) { ... } Binds complex types and simple types out-of-the-box.
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Decorate model properties: public class User { [Required] [EmailAddress] public string Email { get; set; } } Automatically validated during model binding. Use ModelState.IsValid to check.
Decorate model properties: public class User { [Required] [EmailAddress] public string Email { get; set; }
} Automatically validated during model binding. Use ModelState.IsValid to check.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: IValidatableObject: public IEnumerable<ValidationResult> Validate(ValidationContext context) Custom Attribute: public class MyCustomAttribute : ValidationAttribute {
public override bool IsValid(object value) { ... }
}
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Layouts: Shared structure (e.g. header, footer) using _Layout.cshtml. Partial Views: Reusable UI snippets (_LoginPartial.cshtml). View Components: Partial views with logic. public class CartViewComponent : ViewComponent {
public IViewComponentResult Invoke() => View("Cart", model); }
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Via ViewBag / ViewData / Model: return View(model); // Strongly typed ViewBag.Message = "Hello"; ViewData["Count"] = 5;
Via ViewBag / ViewData / Model: return View(model); // Strongly typed
ViewBag.Message = "Hello";
ViewData["Count"] = 5;
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: ActionFilter: Runs before/after action method. ResultFilter: Runs before/after view result. ExceptionFilter: Catches unhandled exceptions. Apply globally or via attributes. public class LogActionFilter : IActionFilter { ... }
A ShopNest ValidateModelAttribute runs before actions and returns 400 if ModelState is invalid—same rule for every controller.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Razor Pages use handler methods: public class IndexModel : PageModel {
public void OnGet() { ... }
public IActionResult OnPost() { ... }
} You can use asp-page-handler="Update" for custom methods.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Inject services into PageModel constructor: public IndexModel(IMyService service) { ... } Also available in Razor views via @inject: @inject ILogger<MyPage> Logger
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Reusable libraries that contain Razor views, pages, static files, etc. Share UI components across multiple projects. dotnet new razorclasslib
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Used to organize large applications into sections (e.g., Admin, Customer). Each Area has its own Controllers/Views/Models. [Area("Admin")] public class DashboardController : Controller { ... }
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Handled via: ASP.NET Core Middleware WebOptimizer, Gulp, or Webpack Static files in wwwroot/ Enable in Startup.cs: app.UseStaticFiles();
Handled via: ASP.NET Core Middleware WebOptimizer, Gulp, or Webpack Static files in wwwroot/ Enable in Startup.cs: app.UseStaticFiles();
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: ASP.NET Core supports Razor by default. You can add support for custom view engines by implementing IViewEngine.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Use IStringLocalizer<T> or IViewLocalizer: @inject IViewLocalizer Localizer <h1>@Localizer["Welcome"]</h1> Add resource .resx files for each language.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: Performance: Very similar, both use Razor rendering. Simplicity: Razor Pages have less boilerplate for page-based UIs. Maintainability: Razor Pages better for small apps, MVC better for large, modular apps. Web API (RESTful Services) Web API (RESTful Services)
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: REST (Representational State Transfer) is an architectural style for building scalable web services. RESTful APIs follow standard HTTP methods (GET, POST, PUT, DELETE) and stateless communication.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: SP.NET Core. ✅ Benefits: Automatic model validation Infer [FromBody] / [FromQuery], etc. 400 BadRequest returned automatically if model state is invalid. Improved parameter binding behavior
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: The [ApiController] attribute is used to denote Web API controllers in ASP.NET Core. ✅ Benefits: Automatic model validation Infer [FromBody] / [FromQuery], etc. 400 BadRequest returned automatically if model state is invalid. Improved parameter binding behavior
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: templates) Attribute Routing (Preferred): [Route("api/products")] [ApiController] public class ProductsController : ControllerBase { [HttpGet("{id}")] public IActionResult Get(int id) { ... } } Route Templates: Use placeholders like {id}, constraints like {id:int}. You can also define route prefixes at controller level and use relative routes in actions.
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: pplication/vnd.company.v1+json services.AddApiVersioning(options => { options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0); }); pplication/vnd.company.v1+json services.AddApiVersioning(options => { options.ReportApiVersions = true;… options.AssumeDefaultVersionWhenUnspecified…… = true; options.DefaultApiVersion = new ApiVersion(1, 0);…
}); pplication/vnd.company.v1+json services.AddApiVersioning(options => { options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0); }); pplication/vnd.company.v1+json services.AddApiVersioning(options => { options.ReportApiVersions = true;… options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0); });
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: media type versioning) Use Microsoft.AspNetCore.Mvc.Versioning package. ✅ Supported methods: URL versioning: /api/v1/products Header versioning: X-API-Version: 1.0 Media Type versioning: Accept: application/vnd.company.v1+json services.AddApiVersioning(options => { options.ReportApiVersions = true;
options.AssumeDefaultVersionWhenUnspecified = true;
options.DefaultApiVersion = new ApiVersion(1, 0); });
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: ASP.NET Core selects the response format based on the Accept header. JSON is the default. To add XML: services.AddControllers() .AddXmlSerializerFormatters(); Accept: application/xml
A ShopNest checkout request flows through middleware, hits a minimal API or controller, uses scoped services, and returns ProblemDetails on errors.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Short answer: SP.NET Core infers the source when possible.
ShopNest registers AppDbContext as Scoped and IMemoryCache as Singleton. Putting DbContext in a Singleton causes threading bugs.