DeveloperExceptionPage (for development) Example:?
pp.UseExceptionHandler("/Home/Error");
or
public class GlobalExceptionFilter : IExceptionFilter
{
public void OnException(ExceptionContext context)
{
context.Result = new ViewResult { ViewName = "Error" };
}
}
🧩 19. How to return partial views?
Partial views are used to render reusable page sections (like headers, sidebars).
Example:
public IActionResult ProductList()
{
var products = _service.GetAll();
return PartialView("_ProductListPartial", products);
}
In Razor:
@Html.Partial("_ProductListPartial", Model.Products)
🧾 20. Explain Razor Pages vs MVC.
Feature Razor Pages MVC
Structure Page-based (.cshtml +
.cshtml.cs)
Controller + View
Best For Simple or CRUD pages Complex or large web apps
URL /Products/Edit →
/Pages/Products/Edit.cshtml
/Products/Edit →
ProductController.Edit()
Code
Location
In the same file (PageModel) Separate Controller class
Example:
Razor Pages are like simplified MVC without controllers — great for admin dashboards or
forms.
Dependency Injection (DI)