Getting Started with ABP: A Step-by-Step Tutorial
With the help of pre-made modules, tools, and templates, AspNet Boilerplate (ABP), a well-liked web application framework, developers may create more straightforward, durable, and current apps. In this article, we’ll walk you through building a basic web application to get you started with ABP.
Prerequisites
Before we begin, make sure you have the following installed on your system:
- Visual Studio 2019 or later
- .NET 5.0 SDK or later
- Node.js and NPM
Step 1: Creating a new ABP project
To create a new ABP project, we’ll use the ABP CLI tool. Open a command prompt and run the following command:
dotnet tool install -g Volo.Abp.Cli
This will install the ABP CLI tool globally on your system.
Next, navigate to the directory where you want to create your new project and run the following command:
abp new MyProjectName
Replace MyProjectName
with the name of your project.
This will create a new ABP project with a basic structure and some pre-built modules.
Step 2: Running the application
To run the application, navigate to the project directory and run the following command:
dotnet run
This will start the application and open it in your default web browser.
Step 3: Creating a new module
To create a new module, use the ABP CLI tool again. Run the following command:
abp add-module MyModuleName
Replace MyModuleName
with the name of your module.
This will create a new module in your project with some basic files and folders.
Step 4: Adding a new controller
To add a new controller to your module, create a new class in the Controllers
folder of your module. Here’s an example:
using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; namespace MyCompanyName.MyProjectName.MyModuleName.Controllers { [Route("api/[controller]")] public class MyController : AbpController { [HttpGet] public ActionResult<string> Get() { return "Hello, World!"; } } }
This controller returns a simple message when you access the URL /api/my
.
Step 5: Testing the controller
To test the controller, start the application again and open your web browser. Navigate to the URL https://localhost:44330/swagger/index.html
to open the Swagger UI.
In the Swagger UI, expand the MyModuleName
section and click on the My
endpoint. Click the Try it out
button and then click the Execute
button. You should see the message “Hello, World!” in the response body.
Conclusion
In this article, we demonstrated how to set up ABP by building a straightforward web application. The fundamental procedures of starting a new project, launching the application, adding a module, adding a controller, and testing the controller with the Swagger UI were addressed.
You may speed up the development process and create a more reliable and scalable application with the use of ABP’s modular design, pre-built modules, tools, and templates. Instead of wasting time on boilerplate code, you can concentrate on developing the essential elements of your application using ABP.
Comments (3)
It is a good platform, I worked as a backend developer for about 15 months using this
hi everyone
I want to add new record in the ‘AbpUserRoles’ table inside code. please help me.
tnx.
Please refer to this documentation page:
https://aspnetboilerplate.com/Pages/Documents/Zero/Role-Management