From ddb4f82dbd92c5f1fbda3701c0d82fdfc4fa4a2d Mon Sep 17 00:00:00 2001 From: bicijinlian Date: Fri, 30 Apr 2021 18:03:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CorsClient/CorsClient/wwwroot/Index.html | 2 +- .../Controllers/CorsController.cs | 16 ++++++++++++++++ .../Controllers/TestController.cs | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CorsClient/CorsClient/wwwroot/Index.html b/CorsClient/CorsClient/wwwroot/Index.html index 4c69ef0..d9748c9 100644 --- a/CorsClient/CorsClient/wwwroot/Index.html +++ b/CorsClient/CorsClient/wwwroot/Index.html @@ -50,7 +50,7 @@
  • 简单API
  • 全局跨域策略
  • 不允许跨域
  • -
  • 单独明确可以跨域
  • +
  • 单独明确可以跨域
  • diff --git a/CorsServer/CorsServer.WebApi31/Controllers/CorsController.cs b/CorsServer/CorsServer.WebApi31/Controllers/CorsController.cs
    index 30aeffd..ed56c88 100644
    --- a/CorsServer/CorsServer.WebApi31/Controllers/CorsController.cs
    +++ b/CorsServer/CorsServer.WebApi31/Controllers/CorsController.cs
    @@ -18,6 +18,11 @@ namespace CorsServer.WebApi31.Controllers
             }
     
             [HttpGet]
    +        [HttpPut]
    +        [HttpHead]
    +        [HttpPost]
    +        [HttpDelete]
    +        [HttpPatch]
             [HttpOptions]
             public IActionResult Ping()
             {
    @@ -27,6 +32,11 @@ namespace CorsServer.WebApi31.Controllers
             }
     
             [HttpGet]
    +        [HttpPut]
    +        [HttpHead]
    +        [HttpPost]
    +        [HttpDelete]
    +        [HttpPatch]
             [HttpOptions]
             [EnableCors(CorsPolicyNameConst.DefaultPolicyName)]
             public IActionResult HasCors()
    @@ -36,7 +46,13 @@ namespace CorsServer.WebApi31.Controllers
                 return Ok(data);
             }
     
    +
             [HttpGet]
    +        [HttpPut]
    +        [HttpHead]
    +        [HttpPost]
    +        [HttpDelete]
    +        [HttpPatch]
             [HttpOptions]
             [DisableCors]
             public IActionResult NoCors()
    diff --git a/CorsServer/CorsServer.WebApi31/Controllers/TestController.cs b/CorsServer/CorsServer.WebApi31/Controllers/TestController.cs
    index 40c8a06..9d355e7 100644
    --- a/CorsServer/CorsServer.WebApi31/Controllers/TestController.cs
    +++ b/CorsServer/CorsServer.WebApi31/Controllers/TestController.cs
    @@ -19,6 +19,12 @@ namespace CorsServer.WebApi31.Controllers
             }
     
             [HttpGet]
    +        [HttpPut]
    +        [HttpHead]
    +        [HttpPost]
    +        [HttpDelete]
    +        [HttpPatch]
    +        [HttpOptions]
             public IActionResult Ping()
             {
                 var data = new { Code=0,Message="Ok" };