Skip to content

Commit

Permalink
general idea of fix for aspnet#147
Browse files Browse the repository at this point in the history
  • Loading branch information
Trofimov Ivan Andreevich committed Aug 8, 2018
1 parent c40bca3 commit a890df4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/System.Web.Cors/CorsPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public CorsPolicy()
/// </summary>
public bool SupportsCredentials { get; set; }

/// <summary>
/// Gets or sets a value indicating whether upstream exceptions should be rethrown.
/// </summary>
public bool RethrowExceptions { get; set; }

/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/System.Web.Http.Cors/CorsMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage
CorsRequestContext corsRequestContext = request.GetCorsRequestContext();
if (corsRequestContext != null)
{
CorsPolicy corsPolicy = await GetCorsPolicyAsync(request, cancellationToken);
try
{
if (corsRequestContext.IsPreflight)
Expand All @@ -60,6 +61,9 @@ protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage
}
catch (Exception exception)
{
if (corsPolicy.RethrowExceptions)
throw;

return HandleException(request, exception);
}
}
Expand Down

0 comments on commit a890df4

Please sign in to comment.