locked
Difference between ASP.Net Core 3 template and ASP.Net Core Web API template RRS feed

  • Question

  • User1242168447 posted

    Hi I'm new to ASP.Net Core,

    I just want to know more in detail, the difference between an ASP.Net Core MVC 3 template and ASP.Net Core Web API template.

    I'm a bit confused as most of the time, if I want to create a web api, I firstly create a ASP.Net Core MVC or Razor project like I saw on Microsoft online Documentation, then I just add a web api (right-click the project \ Add \ New Scaffolded Item... \ Web API \ Web API 2 Controller with actions, using Entity Framework).

    Today I open VS, then I see a WebAPI template... after choosing it, I wait it to open, then I see that it has a lot of files, and it's seems more complex than a regular ASP.Net Core MVC template. 

    Now I got confused, the web api template is really confusing me.

    In brief, what is the best way to create a webapi in asp.net core 3 ??

    Do I always need to pass thru MVC template and add a web api or I only need to go straight to webapi template ?

    Wednesday, April 21, 2021 1:49 AM

Answers

  • User1686398519 posted

    Hi LetMeCode, 

    In brief, what is the best way to create a webapi in asp.net core 3 ??

    It depends on your current needs.

    1. You can mix Web API and MVC controllers in a single project to process advanced AJAX requests, which may return data in JSON, XML or any other format and build a complete HTTP service.
    2. However, if you have your own project architecture and need encapsulated APIs, you can create a separate Web API project.
      1. For example, when you use a layered architecture, the API layer can be separated, and the application can restrict which layers can communicate with other layers.
      2. By limiting which layers depend on which other layers, the impact of changes can be mitigated so that a single change doesn't impact the entire application.

    Common web application architectures

    Best Regards,

    YihuiSun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 21, 2021 7:51 AM