Skip to content

Commit 46fab18

Browse files
Merge pull request #17710 from dotnet/master
Merge to live again on 9 March
2 parents 4506a8f + da3a0c8 commit 46fab18

32 files changed

Lines changed: 1438 additions & 166 deletions

aspnetcore/blazor/layouts/sample_snapshot/3.x/App1.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Router AppAssembly="typeof(Startup).Assembly">
1+
<Router AppAssembly="@typeof(Startup).Assembly">
22
<Found Context="routeData">
33
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
44
</Found>

aspnetcore/blazor/layouts/sample_snapshot/3.x/App2.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Router AppAssembly="typeof(Startup).Assembly">
1+
<Router AppAssembly="@typeof(Startup).Assembly">
22
<Found Context="routeData">
33
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
44
</Found>

aspnetcore/fundamentals/configuration/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Configuration keys:
305305
* Hierarchical keys
306306
* Within the Configuration API, a colon separator (`:`) works on all platforms.
307307
* In environment variables, a colon separator may not work on all platforms. A double underscore, `__`, is supported by all platforms and is automatically converted into a colon `:`.
308-
* In Azure Key Vault, hierarchical keys use `--` as a separator. Write code to replace the `--` with a `:` when the secrets are loaded into the app's configuration.
308+
* In Azure Key Vault, hierarchical keys use `--` as a separator. The [Azure Key Vault configuration provider](xref:security/key-vault-configuration) automatically replaces `--` with a `:` when the secrets are loaded into the app's configuration.
309309
* The <xref:Microsoft.Extensions.Configuration.ConfigurationBinder> supports binding arrays to objects using array indices in configuration keys. Array binding is described in the [Bind an array to a class](#boa) section.
310310

311311
Configuration values:

aspnetcore/security/cors.md

Lines changed: 332 additions & 158 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "3.1.2",
7+
"commands": [
8+
"dotnet-ef"
9+
]
10+
}
11+
}
12+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Microsoft.AspNetCore.Cors;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Docs.Samples;
4+
5+
namespace WebAPI.Controllers
6+
{
7+
#region snippet2
8+
[Route("api/[controller]")]
9+
[ApiController]
10+
public class TodoItems1Controller : ControllerBase
11+
{
12+
// PUT: api/TodoItems1/5
13+
[HttpPut("{id}")]
14+
public IActionResult PutTodoItem(int id)
15+
{
16+
if (id < 1)
17+
{
18+
return Content($"ID = {id}");
19+
}
20+
21+
return ControllerContext.MyDisplayRouteInfo(id);
22+
}
23+
24+
// Delete: api/TodoItems1/5
25+
[HttpDelete("{id}")]
26+
public IActionResult MyDelete(int id) =>
27+
ControllerContext.MyDisplayRouteInfo(id);
28+
29+
// GET: api/TodoItems1
30+
[HttpGet]
31+
public IActionResult GetTodoItems() =>
32+
ControllerContext.MyDisplayRouteInfo();
33+
34+
[EnableCors]
35+
[HttpGet("{action}")]
36+
public IActionResult GetTodoItems2() =>
37+
ControllerContext.MyDisplayRouteInfo();
38+
39+
// Delete: api/TodoItems1/MyDelete2/5
40+
[EnableCors]
41+
[HttpDelete("{action}/{id}")]
42+
public IActionResult MyDelete2(int id) =>
43+
ControllerContext.MyDisplayRouteInfo(id);
44+
}
45+
#endregion
46+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using Microsoft.AspNetCore.Cors;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Docs.Samples;
4+
5+
// Used in both the MD file and the RP Test.cshtml
6+
7+
namespace WebAPI.Controllers
8+
{
9+
#region snippet2
10+
#region snippet
11+
[Route("api/[controller]")]
12+
[ApiController]
13+
public class TodoItems2Controller : ControllerBase
14+
{
15+
// OPTIONS: api/TodoItems2/5
16+
[HttpOptions("{id}")]
17+
public IActionResult PreflightRoute(int id)
18+
{
19+
return NoContent();
20+
}
21+
22+
// OPTIONS: api/TodoItems2
23+
[HttpOptions]
24+
public IActionResult PreflightRoute()
25+
{
26+
return NoContent();
27+
}
28+
29+
[HttpPut("{id}")]
30+
public IActionResult PutTodoItem(int id)
31+
{
32+
if (id < 1)
33+
{
34+
return BadRequest();
35+
}
36+
37+
return ControllerContext.MyDisplayRouteInfo(id);
38+
}
39+
#endregion
40+
41+
// [EnableCors] // Not needed as OPTIONS path provided
42+
[HttpDelete("{id}")]
43+
public IActionResult MyDelete(int id) =>
44+
ControllerContext.MyDisplayRouteInfo(id);
45+
46+
[EnableCors] // Rquired for this path
47+
[HttpGet]
48+
public IActionResult GetTodoItems() =>
49+
ControllerContext.MyDisplayRouteInfo();
50+
51+
[HttpGet("{action}")]
52+
public IActionResult GetTodoItems2() =>
53+
ControllerContext.MyDisplayRouteInfo();
54+
55+
[EnableCors] // Rquired for this path
56+
[HttpDelete("{action}/{id}")]
57+
public IActionResult MyDelete2(int id) =>
58+
ControllerContext.MyDisplayRouteInfo(id);
59+
}
60+
#endregion
61+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Microsoft.AspNetCore.Cors;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace WebAPI.Controllers
5+
{
6+
#region snippet
7+
[Route("api/[controller]")]
8+
[ApiController]
9+
public class TodoItemsController : ControllerBase
10+
{
11+
// PUT: api/TodoItems/5
12+
[HttpPut("{id}")]
13+
public ContentResult PutTodoItem(int id)
14+
{
15+
if (id < 1)
16+
{
17+
return Content($"ID = {id}");
18+
}
19+
20+
return Content($"PutTodoItem: ID = {id}");
21+
}
22+
23+
// Delete: api/TodoItems/5
24+
[HttpDelete("{id}")]
25+
public ContentResult MyDelete(int id)
26+
{
27+
return Content($"MyDelete: ID = {id}");
28+
}
29+
#endregion
30+
31+
// GET: api/TodoItems
32+
[HttpGet]
33+
public ContentResult GetTodoItems()
34+
{
35+
return Content("Get TO DO ");
36+
}
37+
}
38+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Microsoft.AspNetCore.Cors;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.Docs.Samples;
4+
5+
namespace WebAPI.Controllers
6+
{
7+
#region snippet
8+
[EnableCors("MyPolicy")]
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
public class ValuesController : ControllerBase
12+
{
13+
// GET api/values
14+
[HttpGet]
15+
public IActionResult Get() =>
16+
ControllerContext.MyDisplayRouteInfo();
17+
18+
// GET api/values/5
19+
[HttpGet("{id}")]
20+
public IActionResult Get(int id) =>
21+
ControllerContext.MyDisplayRouteInfo(id);
22+
23+
// PUT api/values/5
24+
[HttpPut("{id}")]
25+
public IActionResult Put(int id) =>
26+
ControllerContext.MyDisplayRouteInfo(id);
27+
28+
29+
// GET: api/values/GetValues2
30+
[DisableCors]
31+
[HttpGet("{action}")]
32+
public IActionResult GetValues2() =>
33+
ControllerContext.MyDisplayRouteInfo();
34+
35+
}
36+
#endregion
37+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.AspNetCore.Cors;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System.Collections.Generic;
4+
5+
namespace WebAPI.Controllers
6+
{
7+
#region snippet
8+
[Route("api/[controller]")]
9+
[ApiController]
10+
public class WidgetController : ControllerBase
11+
{
12+
// GET api/values
13+
[EnableCors("AnotherPolicy")]
14+
[HttpGet]
15+
public ActionResult<IEnumerable<string>> Get()
16+
{
17+
return new string[] { "green widget", "red widget" };
18+
}
19+
20+
#region snippet2
21+
// GET api/values/5
22+
[EnableCors("Policy1")]
23+
[HttpGet("{id}")]
24+
public ActionResult<string> Get(int id)
25+
{
26+
return id switch
27+
{
28+
1 => "green widget",
29+
2 => "red widget",
30+
_ => NotFound(),
31+
};
32+
}
33+
#endregion
34+
}
35+
#endregion
36+
}

0 commit comments

Comments
 (0)