Table of Contents

Class ExceptionResult

Namespace
System.Web.Http.Results
Assembly
System.Web.Http.dll

Represents an action result that returns a InternalServerError response and performs content negotiation on an HttpError  based on an Exception.

public class ExceptionResult : IHttpActionResult
Inheritance
ExceptionResult
Implements
Inherited Members

Constructors

ExceptionResult(Exception, bool, IContentNegotiator, HttpRequestMessage, IEnumerable<MediaTypeFormatter>)

Initializes a new instance of the ExceptionResult class.

public ExceptionResult(Exception exception, bool includeErrorDetail, IContentNegotiator contentNegotiator, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)

Parameters

exception Exception

The exception to include in the error.

includeErrorDetail bool

true if the error should include exception messages; otherwise, false .

contentNegotiator IContentNegotiator

The content negotiator to handle content negotiation.

request HttpRequestMessage

The request message which led to this result.

formatters IEnumerable<MediaTypeFormatter>

The formatters to use to negotiate and format the content.

ExceptionResult(Exception, ApiController)

Initializes a new instance of the ExceptionResult class.

public ExceptionResult(Exception exception, ApiController controller)

Parameters

exception Exception

The exception to include in the error.

controller ApiController

The controller from which to obtain the dependencies needed for execution.

Properties

ContentNegotiator

Gets the content negotiator to handle content negotiation.

public IContentNegotiator ContentNegotiator { get; }

Property Value

IContentNegotiator

Returns System.Net.Http.Formatting.IContentNegotiator.

Exception

Gets the exception to include in the error.

public Exception Exception { get; }

Property Value

Exception

Returns Exception.

Formatters

Gets the formatters to use to negotiate and format the content.

public IEnumerable<MediaTypeFormatter> Formatters { get; }

Property Value

IEnumerable<MediaTypeFormatter>

Returns IEnumerable<T>.

IncludeErrorDetail

Gets a value indicating whether the error should include exception messages.

public bool IncludeErrorDetail { get; }

Property Value

bool

Returns bool.

Request

Gets the request message which led to this result.

public HttpRequestMessage Request { get; }

Property Value

HttpRequestMessage

Returns HttpRequestMessage.

Methods

ExecuteAsync(CancellationToken)

public virtual Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

Returns Task<TResult>.