Sunday 8 December 2019

Create a Simple asp dot net core application in 10 Steps

Hello Friends,

         Now I am going to describe how to Create a Simple asp dot net core application in Ten Steps.Next Session will be discuss the web api application with db connection using entity framework .I hope it will be  helpful for all of my friends.

Step-1:Open Visual Studio ->Create New Project and select "Asp.net Core Web Application" ->Click on OK















Step-2:Select API and click on OK
Step-3:Right click on Controller->Add->Controller
Step-4:Select "API Controller - Empty" then Click on Add Button
















Step-5:Rename the Controller and Click on Add button
Step-6:After create this Controller please write below code and Press F5 to run both Scenario through Simple  Get( [HttpGet]) and Get by Id( [HttpGet("{id}")])

Web Api Code of  this Controller "TestApiController.cs":

using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace FirstWebapiApplication.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TestApiController : ControllerBase
    {
        [HttpGet]
        public string getmywebapi()
        {
            return "hello world....";
        }
        [HttpGet("{id}")]
        public List<string> getmywebapi(int Id)
        {
            return new List<string>
            {
                "Welcome To First Web Api",
                "welcome to api application",
                "hello world..."
            };
        }
    }
}

Step-7: Before run application we should change our controller name in "lunchSettings.json" page in "launchUrl" name  like in below configuration.
Step-8:Configure Setting of Controller in highlighted field 
After Configuration Build this Solution then Press F5 to Run the Application:
Step-9:Press F5 to See the output For Get( [HttpGet]) method:









Step-10:Press F5 to See the output For Get by Id([HttpGet("{id}")]) method:



In this session I’ve explained how to Create a Simple asp dot net core application within 10 steps in Visual Studio 2017. So after read please Comments and suggestions.

Thanks & Regard
Rabi

No comments:

Post a Comment