DeveloperExceptionPage (for development) Example: app.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:
Follow :
@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)