Skip to content

Commit c88fae0

Browse files
authored
Add note re placement of UseCors (#17884)
1 parent a3ce1db commit c88fae0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

aspnetcore/security/cors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: rick-anderson
44
description: Learn how CORS as a standard for allowing or rejecting cross-origin requests in an ASP.NET Core app.
55
ms.author: riande
66
ms.custom: mvc
7-
ms.date: 01/23/2020
7+
ms.date: 04/17/2020
88
uid: security/cors
99
---
1010
# Enable Cross-Origin Requests (CORS) in ASP.NET Core
@@ -65,7 +65,7 @@ CORS Middleware handles cross-origin requests. The following code applies a CORS
6565
The preceding code:
6666

6767
* Sets the policy name to `_myAllowSpecificOrigins`. The policy name is arbitrary.
68-
* Calls the <xref:Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions.UseCors*> extension method and specifies the `_myAllowSpecificOrigins` CORS policy. `UseCors` adds the CORS middleware.
68+
* Calls the <xref:Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions.UseCors*> extension method and specifies the `_myAllowSpecificOrigins` CORS policy. `UseCors` adds the CORS middleware. The call to `UseCors` must be placed after `UseRouting`, but before `UseAuthorization`. For more information, see [Middleware order](xref:fundamentals/middleware/index#middleware-order).
6969
* Calls <xref:Microsoft.Extensions.DependencyInjection.CorsServiceCollectionExtensions.AddCors*> with a [lambda expression](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions). The lambda takes a <xref:Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder> object. [Configuration options](#cors-policy-options), such as `WithOrigins`, are described later in this article.
7070
* Enables the `_myAllowSpecificOrigins` CORS policy for all controller endpoints. See [endpoint routing](#ecors) to apply a CORS policy to specific endpoints.
7171

0 commit comments

Comments
 (0)