Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

.net return context.Result without extra new objectResult

public class ErrorModel
{
    public string Error { get; set; }

    public int Id { get; set; }

    public List<int> Values { get; set; }
}

//filter

var error = new ErrorModel
{
    Error = context.Exception.Message,
    Id = 1,
    Values = new List<int> { 1, 2, 3 }
};
context.Result = new ObjectResult(error)
{
    StatusCode = 500
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #return #extra #objectResult
ADD COMMENT
Topic
Name
5+2 =