The SPA template does not meet current .NET Community best practices for building a Web API. If you go to File->New Project in Visual Studio for a Web API in .NET Framework or .NET Core you will see the disconnects that this PR aims to fix.
Regions are not recommended for new projects, let the developer decide if they want to use them. They are not recommended anymore
Namespace change - Services -> Controllers. The DnnApiController inherits from the ApiController which makes it a Controller and not a Service.
DTO -> Models. On a basic Web API the term Models is more widely accepted than DTO which is typically used closer to the database in large N-Tier applications. The model should also exist in it's own Models namespace and not a 2nd class in the MyController.cs file.
Defaulting a BaseController in the template is a little bit of a code smell as not everyone will use it. The template should start with a lean starting point, not a bunch of samples of how to do this. See the standard visual studio templates for Web APIs.
Updating MyController -> HomeController. In the standard .NET Templates found in Visual Studio for .NET Framework and .NET Core the default controller is called HomeController
These are recommendations based on my experience outside of DNN in the .NET Community and what I have seen as standards from official Visual Studio templates. They may be different than what DNN has done historically but if we want greater interop with developers coming from standard .NET this will be a good direction to go.
The SPA template does not meet current .NET Community best practices for building a Web API. If you go to File->New Project in Visual Studio for a Web API in .NET Framework or .NET Core you will see the disconnects that this PR aims to fix.
DnnApiController
inherits from theApiController
which makes it aController
and not aService
.Models
is more widely accepted than DTO which is typically used closer to the database in large N-Tier applications. The model should also exist in it's ownModels
namespace and not a 2nd class in the MyController.cs file.BaseController
in the template is a little bit of a code smell as not everyone will use it. The template should start with a lean starting point, not a bunch of samples of how to do this. See the standard visual studio templates for Web APIs.HomeController
These are recommendations based on my experience outside of DNN in the .NET Community and what I have seen as standards from official Visual Studio templates. They may be different than what DNN has done historically but if we want greater interop with developers coming from standard .NET this will be a good direction to go.