DefaultAllowCorsPolicy 1.0.0
See the version list below for details.
dotnet add package DefaultAllowCorsPolicy --version 1.0.0
NuGet\Install-Package DefaultAllowCorsPolicy -Version 1.0.0
<PackageReference Include="DefaultAllowCorsPolicy" Version="1.0.0" />
paket add DefaultAllowCorsPolicy --version 1.0.0
#r "nuget: DefaultAllowCorsPolicy, 1.0.0"
// Install DefaultAllowCorsPolicy as a Cake Addin #addin nuget:?package=DefaultAllowCorsPolicy&version=1.0.0 // Install DefaultAllowCorsPolicy as a Cake Tool #tool nuget:?package=DefaultAllowCorsPolicy&version=1.0.0
DefaultAllowCorsPolicy NuGet Package
This NuGet package facilitates adding a default Cross-Origin Resource Sharing (CORS) policy to your ASP.NET Core projects.
Installation
To add the package to your project, you can use either the Package Manager Console or the .NET CLI:
dotnet add package DefaultAllowCorsPolicyNugetPackage
or
Install-Package DefaultAllowCorsPolicyNugetPackage
Usage
After adding the package to your project, you can register the service in your Startup.cs
file as follows:
using DefaultAllowCorsPolicyNugetPackage;
using Microsoft.Extensions.DependencyInjection;
public class Startup
{
// ...
public void ConfigureServices(IServiceCollection services)
{
// Other service configurations
// Add DefaultAllowCorsPolicy
services.AddDefaultCors();
// ...
}
// ...
}
This adds a CORS policy allowing all requests.
CORS Policy
This package adds a CORS policy that allows all headers, all methods, credentials, and allows any origin. This policy can be useful during development or in scenarios where specific security requirements are not necessary. It is recommended to customize the policy for security requirements.
services.AddCors(cfr =>
{
cfr.AddDefaultPolicy(policy =>
{
policy
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()
.SetIsOriginAllowed(policy => true);
});
});
Licence
This project is licensed under the MIT License.
This sample README file provides essential information regarding the installation, usage, and CORS policy of the project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Cors (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.