From 8ebe0a2d29adecd924fee934ece0e47c42939b77 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Mon, 8 Jan 2018 15:08:43 -0800 Subject: [PATCH] Derive Web API templates from ControllerBase (#220) Addresses #45 --- .../content/EmptyWeb-FSharp/Startup.fs | 1 + .../content/StarterWeb-FSharp/Startup.fs | 4 ++++ .../content/WebApi-CSharp/Controllers/ValuesController.cs | 7 ++++--- .../content/WebApi-FSharp/Controllers/ValuesController.fs | 7 ++++--- .../content/WebApi-FSharp/Startup.fs | 4 ++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs index 142130c1f0..2709a8aa3c 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs @@ -1,5 +1,6 @@ namespace Company.WebApplication1 +open System open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.Http diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs index a00f0e005e..5c98f8c54d 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs @@ -1,5 +1,9 @@ namespace Company.WebApplication1 +open System +open System.Collections.Generic +open System.Linq +open System.Threading.Tasks open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.HttpsPolicy diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Controllers/ValuesController.cs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Controllers/ValuesController.cs index 612508ce71..d633e698e3 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Controllers/ValuesController.cs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Controllers/ValuesController.cs @@ -13,7 +13,8 @@ namespace Company.WebApplication1.Controllers [Authorize] #endif [Route("api/[controller]")] - public class ValuesController : Controller + [ApiController] + public class ValuesController : ControllerBase { // GET api/values [HttpGet] @@ -31,7 +32,7 @@ namespace Company.WebApplication1.Controllers // POST api/values [HttpPost] - public void Post([FromBody]string value) + public void Post([FromBody] string value) { #if (OrganizationalAuth || WindowsAuth) // For more information on protecting this API from Cross Site Request Forgery (CSRF) attacks, see https://go.microsoft.com/fwlink/?LinkID=717803 @@ -40,7 +41,7 @@ namespace Company.WebApplication1.Controllers // PUT api/values/5 [HttpPut("{id}")] - public void Put(int id, [FromBody]string value) + public void Put(int id, [FromBody] string value) { #if (OrganizationalAuth || WindowsAuth) // For more information on protecting this API from Cross Site Request Forgery (CSRF) attacks, see https://go.microsoft.com/fwlink/?LinkID=717803 diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Controllers/ValuesController.fs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Controllers/ValuesController.fs index b26a809bb4..fe84a68d83 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Controllers/ValuesController.fs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Controllers/ValuesController.fs @@ -7,8 +7,9 @@ open System.Threading.Tasks open Microsoft.AspNetCore.Mvc [] +[] type ValuesController () = - inherit Controller() + inherit ControllerBase() [] member this.Get() = @@ -19,11 +20,11 @@ type ValuesController () = "value" [] - member this.Post([]value:string) = + member this.Post([] value:string) = () [] - member this.Put(id:int, []value:string ) = + member this.Put(id:int, [] value:string ) = () [] diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs index bc17f8cefa..bc074908c1 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs @@ -1,5 +1,9 @@ namespace Company.WebApplication1 +open System +open System.Collections.Generic +open System.Linq +open System.Threading.Tasks open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.HttpsPolicy