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)
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png