Create a versioned and documented ASP.NET Core Web API

Create a versioned and documented ASP.NET Core Web API

ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core 1.0 hosting. Let’s create a versioned and semi-automatically documented Web API, this could be done both for public API, and quite useful for, internal-use API’s as well.The ASP.NET Core Web API Project Create a new project Visual C# > .NET Core > ASP.NET Core Web Application and give a descriptive name to your API. We’re going to add three NuGet packages:Install-Package Microsoft.AspNetCore.Mvc.Versioning Install-Package Swashbuckle.AspNetCore -Pre Install-Package SwashbuckleAspNetVersioningShim -Pre Two of these packages are prerelease packages but they are fully functional You can now remove the automatically created ValuesController.cs and let’s add a new HelloController.csusing Microsoft.AspNetCore.Mvc;namespace VersionedWebApi.Controllers { /// <summary> /// HelloController, just saying Hello World! /// </summary> [ApiVersion("1.0", Deprecated = true)] [Route("api/v{version:apiVersion}/[controller]")] public class HelloController : Controller { /// <summary> /// Default Get call returning Hello World! ...
Read More
Adding MVC to ASP.NET Core web application

Adding MVC to ASP.NET Core web application

ReviewCoreASPHosting.NET | Best and cheap ASP.NET MVC core hosting. This article refers to an earlier version of the .NET Core SDK and project.json which Microsoft has deprecated in favour of a revamped .csproj file. Now let’s add MVC to the picture. Start off by modifying project.json to require the MVC packages.{ "version": "1.0.0-*", "buildOptions": { "debugType": "portable", "emitEntryPoint": true }, "dependencies": {}, "frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0" }, "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0" }, "imports": "dnxcore50" } ...
Read More