Skip to content

Commit a890df4

Browse files
author
Trofimov Ivan Andreevich
committed
general idea of fix for #147
1 parent c40bca3 commit a890df4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/System.Web.Cors/CorsPolicy.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public long? PreflightMaxAge
8585
/// </summary>
8686
public bool SupportsCredentials { get; set; }
8787

88+
/// <summary>
89+
/// Gets or sets a value indicating whether upstream exceptions should be rethrown.
90+
/// </summary>
91+
public bool RethrowExceptions { get; set; }
92+
8893
/// <summary>
8994
/// Returns a <see cref="System.String" /> that represents this instance.
9095
/// </summary>

src/System.Web.Http.Cors/CorsMessageHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage
4747
CorsRequestContext corsRequestContext = request.GetCorsRequestContext();
4848
if (corsRequestContext != null)
4949
{
50+
CorsPolicy corsPolicy = await GetCorsPolicyAsync(request, cancellationToken);
5051
try
5152
{
5253
if (corsRequestContext.IsPreflight)
@@ -60,6 +61,9 @@ protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage
6061
}
6162
catch (Exception exception)
6263
{
64+
if (corsPolicy.RethrowExceptions)
65+
throw;
66+
6367
return HandleException(request, exception);
6468
}
6569
}

0 commit comments

Comments
 (0)