ASP.NET MVC

ASP.NET MVC guide for Trezo.

Overview

ASP.NET Core MVC with Bootstrap v5 is a powerful combination for developing responsive, feature-rich web applications with modern styling and clean architecture. Here’s a description that outlines the key features and benefits of this setup:

ASP.NET Core MVC with Bootstrap v5 provides a robust framework for building scalable, maintainable, and high-performance web applications. With ASP.NET Core MVC’s clean separation of concerns and server-side rendering capabilities, developers can create applications that are easy to test and maintain. Bootstrap 5, known for its responsive grid system and ready-to-use components, ensures that applications look polished and function seamlessly across devices.

Key Features:

  • MVC Architecture:
    • ASP.NET Core MVC (Model-View-Controller) organizes the application into distinct areas, allowing for clean separation of business logic (Models), UI (Views), and user interactions (Controllers).
    • This structure promotes code reusability, scalability, and testability.
  • Responsive Design with Bootstrap 5:
    • Bootstrap v5’s grid system and flex utilities make it easy to create layouts that adapt to various screen sizes, enhancing the user experience on desktops, tablets, and smartphones.
    • With Bootstrap’s extensive component library (buttons, forms, modals, navbars, etc.), you can implement a professional UI with minimal custom CSS.
  • Customization and Theming:
    • Bootstrap 5’s new customization options allow developers to tailor the look and feel of components to align with branding requirements.
    • By overriding or customizing Bootstrap’s default classes, you can create unique designs while still leveraging the robust framework it offers.
  • Enhanced Performance and Security:
    • ASP.NET Core MVC is known for high performance and low memory consumption, essential for modern web applications.
    • Built-in security features such as authentication, authorization, and data protection ensure that your application remains secure.
  • Seamless Frontend and Backend Integration:
    • ASP.NET Core MVC’s Razor views enable smooth integration with JavaScript and CSS libraries, including Bootstrap 5, providing a seamless frontend-backend experience.
    • With support for modern JavaScript frameworks and libraries, you can enhance the interactivity of your application’s UI.
  • Cross-Platform Capabilities:
    • ASP.NET Core runs on Windows, macOS, and Linux, allowing you to deploy applications on a range of platforms.
    • You can develop and run applications in Visual Studio or VS Code, making it flexible for different development environments.

This setup is ideal for anyone looking to build enterprise-grade web applications with a modern, responsive design and a structured backend.

Dear Valued Customer

Thank you for choosing our product! We hope that your experience with it has been smooth and enjoyable. However, we understand that sometimes technical issues or missing files may arise, and we want you to know that we’re here to help.

If you encounter any issues—whether it’s a missing file, a technical difficulty, or just a question about functionality—please don’t hesitate to reach out to us. You can easily create a support ticket, and our dedicated team will be on hand to assist you promptly.

How to Create a Support Ticket:

  1. Log in to Your Account: Navigate to the support section on our website.
  2. Select "Submit a Ticket Now": This option allows you to provide details of the issue you’re experiencing.
  3. Describe Your Issue: Please include as much information as possible (e.g., specific error messages, screenshots, or details about the steps that led to the issue). This will help us resolve your case quickly and effectively.

Our priority is to ensure you have the best experience possible, and we are committed to providing timely and effective support. We understand that technical issues can be frustrating, and we truly appreciate your patience and understanding as we work to resolve them.

Once again, thank you for your trust in us, and please remember—we’re here to help. Don’t hesitate to create a support ticket for any assistance you may need!

Best regards,

EnvyTheme Support Team

Prerequisites


macOS 12.0 or later versions.

Download and install


To start building .NET apps, download and install the .NET SDK.

Download .NET 8 SDK Arm64 (Apple Silicon) ->

Check everything installed correctly

Once you've installed, open a new terminal and run the following command:

dotnet --version

If the installation succeeded, you should see version 8.0.100 or higher outputted:

8.0.100

Run the app

Navigate to the new asp-core-bootstrap directory.

In your terminal, run the following command:

dotnet run

The dotnet run command will build and start the app, and then update the app whenever you make code changes. You can stop the app at any time by selecting Ctrl+C.

The run command produces output like the following example:

Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5012
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\aspnetcoreapp

Open a browser and go to the URL shown in the output. In this example, the URL is http://localhost:5012.

The browser shows the home page.

screenshot

Adding a New Controller with View in ASP.NET Core MVC

Here’s a detailed guide on how to add a new controller with a view page in an ASP.NET Core MVC application, using HomeController as a reference.

Adding a New Controller with View in ASP.NET Core MVC

  1. Open the Project in Visual Studio:
  • Open your ASP.NET Core MVC project in Visual Studio.
  1. Add a New Controller:
  • Right-click on the Controllers folder in Solution Explorer.
  • Select Add > Controller.
  • Choose MVC Controller - Empty from the options. This template creates a basic controller with minimal setup.
  • Name the controller. For this example, let’s call it ProductController. Visual Studio will automatically add the suffix Controller, so the file will be named ProductController.cs.
  1. Define the Controller Actions:
  • Open ProductController.cs.
  • Add actions to define the logic for the controller. An action represents a method that handles HTTP requests. For example:
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using trezo_asp_mvc.Models;

namespace trezo_asp_mvc.Controllers;

public class ExampleController(ILogger<ExampleController> logger) : Controller
{
    private readonly ILogger<ExampleController> _logger = logger;

    public IActionResult Index()
    {
        return View();
    }

    [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
    public IActionResult Error()
    {
        return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
    }
}
  • In this example, Index action are defined, where Index will be the main page of the Index section.

Add Views for the Controller Actions:

  • Now that we have actions in the ExampleController, we need views to render content for this action.

Creating the Index View:

  • First, add a new folder in the /Views/ directory to organize the views for ExampleController such as Example.
  • Add Index.cshtml.
  • Edit Index.cshtml to include the content you want to display on this page. For example:

Views/Example/Index.cshtml

@{
    ViewData["Title"] = "Example";
}

<h1>@ViewData["Title"]</h1>
<p>This is the example list page.</p>

Support

If you need more details or encounter any issues, please contact the support team.