-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-corsThis issue is related to CORSThis issue is related to CORS
Milestone
Description
Making a call to CorsPolicyBuilder.WithOrigins with an array that contains a null string will cause a NullReferenceException to be thrown rather than throwing against the argument. This was noticed when a configuration file failed to read.
To Reproduce
app.UseCors(builder => builder.WithOrigins(null));
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder.GetNormalizedOrigin(String origin)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder.WithOrigins(String[] origins)
at ###.Startup.<Configure>b__11_0(CorsPolicyBuilder builder) in ###\Startup.cs:line 95
at Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions.UseCors(IApplicationBuilder app, Action`1 configurePolicy)
at ###.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in ###\Startup.cs:line 94
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
It would be beneficial if an ArgumentNullException was thrown instead.
Metadata
Metadata
Assignees
Labels
area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-corsThis issue is related to CORSThis issue is related to CORS