ASP.NET Core MVC View Types

ASP.NET Core MVC View Types

Understanding different view types and Action Results used in Sense Softech ERP / POS applications.

View Type Usage Example
Normal View Displays a full page and returns HTML to the browser.
public IActionResult Index()
{
    return View();
}
Strongly Typed View Passes a Model object from Controller to View (Recommended for forms).
return View(new CustomerModel());
View:
@model CustomerModel
@Model.Name
Partial View Reusable UI components (Grids, Modals, Header, Footer, etc.).
return PartialView("_ItemGrid", model);
View:
@await Html.PartialAsync("_ItemGrid", Model)
ViewBag / ViewData Pass temporary data without creating a model.
ViewBag.BranchName = "Ahmedabad";
ViewData["Title"] = "Stock Report";
TempData Pass data between requests (commonly used after Save/Delete).
TempData["Success"] = "Record saved successfully";
JSON Result Used with AJAX calls (most common in ERP).
return Json(new { success = true, message = "Saved" });
File Result Download PDF, Excel, Images, etc. (Used with iText7 & RDLC).
return File(fileBytes, "application/pdf", "Quotation.pdf");
Redirect Result Redirect user to another action.
return RedirectToAction("Index");

Recommended Usage in ERP Projects

Scenario Recommended View Type
Data Entry / Edit FormStrongly Typed View
Grid / List Refresh (AJAX)Partial View + JSON
Save / Update / DeleteJSON Result
Generate PDF / ExcelFile Result
Success / Error MessageTempData
Reusable ComponentsPartial View

MVC View Folder Structure (Recommended)

Views
├── Shared
│   ├── _Layout.cshtml
│   ├── _Header.cshtml
│   └── _Sidebar.cshtml
├── Customer
│   ├── CustomerEntry.cshtml
│   └── _CustomerGrid.cshtml
├── Reports
│   └── SalesReport.cshtml
└── ViewImports.cshtml

Best Practice:

• Use Strongly Typed Views for all data entry forms.
• Use Partial Views for grids and reusable components.
• Use JSON Result for all AJAX operations.
• Minimize heavy use of ViewBag/ViewData in large projects.
• Always combine with ClsSqlHelper in Controllers.