259 references to Results
Aspire.Dashboard (3)
Otlp\Http\OtlpHttpEndpointsBuilder.cs (3)
47
return
Results
.Empty;
55
return
Results
.Empty;
63
return
Results
.Empty;
Aspire.Dashboard.Tests (6)
Integration\MockOpenIdAuthority.cs (6)
49
return
Results
.Json(new
64
return
Results
.Redirect($"{redirect_uri}?error=interaction_required&state={state}");
70
return
Results
.Redirect($"{redirect_uri}?error=invalid_request&error_description=extraQueryParams%20not%20preserved&state={state}");
74
return
Results
.Redirect($"{redirect_uri}?code={lastCode}&state={state}");
83
return
Results
.BadRequest("Bad code");
86
return
Results
.Json(new
AzureContainerApps.ApiService (1)
Program.cs (1)
23
return
Results
.Content("""
AzureFunctionsEndToEnd.ApiService (4)
Program.cs (4)
30
return
Results
.Ok("Message sent to Azure Storage Queue.");
49
return
Results
.Ok("String uploaded to Azure Storage Blobs.");
56
return
Results
.Ok("Message sent to Azure EventHubs.");
72
return
Results
.Stream(stream, "application/json");
AzureFunctionsEndToEnd.Functions (1)
MyHttpTrigger.cs (1)
38
return
Results
.Text(stringBuilder.ToString());
BasicWebSite (2)
Controllers\ContactApiController.cs (2)
137
=>
Results
.Ok(new Contact() { ContactId = id });
141
=>
Results
.NoContent();
CatalogService (3)
CatalogApi.cs (3)
37
return
Results
.NotFound();
44
return
Results
.NotFound();
47
return
Results
.File(path, "image/jpeg");
EventHubsApi (2)
Program.cs (2)
20
return
Results
.Ok();
28
return
Results
.Accepted();
Microsoft.AspNetCore.Http.Extensions.Tests (3)
RequestDelegateFactoryTests.cs (3)
1859
IResult actionWithExtensionsResult(string name) =>
Results
.Extensions.TestResult(name);
3100
Assert.Same(
Results
.Empty, response);
3812
return
Results
.Ok(FormattableString.Invariant($"Hello {name}. This is from an extension method."));
Microsoft.AspNetCore.Http.Results.Tests (171)
ResultsTests.cs (171)
31
var result =
Results
.Accepted(uri, value) as Accepted<object>;
47
var result =
Results
.Accepted(uri, value) as Accepted<Todo>;
62
var result =
Results
.Accepted(uri) as Accepted;
73
var result =
Results
.Accepted() as Accepted;
89
var result =
Results
.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<object>;
107
var result =
Results
.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<object>;
122
var result =
Results
.AcceptedAtRoute(null, null) as AcceptedAtRoute;
139
var result =
Results
.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<Todo>;
157
var result =
Results
.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<Todo>;
172
var result =
Results
.AcceptedAtRoute<object>(null, null, null) as AcceptedAtRoute;
186
var result =
Results
.AcceptedAtRoute(null, null, null) as AcceptedAtRoute;
202
var result =
Results
.AcceptedAtRoute(routeName, routeValues) as AcceptedAtRoute;
214
var result =
Results
.AcceptedAtRoute() as AcceptedAtRoute;
229
var result =
Results
.BadRequest(value) as BadRequest<object>;
243
var result =
Results
.BadRequest(value) as BadRequest<Todo>;
254
var result =
Results
.BadRequest() as BadRequest;
270
0 =>
Results
.Bytes(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag),
271
_ =>
Results
.File(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag)
301
0 =>
Results
.Stream(stream, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing),
302
1 =>
Results
.Stream(PipeReader.Create(stream), contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing),
303
_ =>
Results
.Stream((s) => Task.CompletedTask, contentType, fileDownloadName, lastModified, entityTag)
344
Assert.Throws<ArgumentNullException>("contents", () =>
Results
.Bytes(null));
350
Assert.Throws<ArgumentNullException>("fileContents", () =>
Results
.File(default(byte[])));
356
Assert.Throws<ArgumentNullException>("fileStream", () =>
Results
.File(default(Stream)));
362
Assert.Throws<ArgumentNullException>("stream", () =>
Results
.Stream(default(Stream)));
368
Assert.Throws<ArgumentNullException>("pipeReader", () =>
Results
.Stream(default(PipeReader)));
382
var result =
Results
.Challenge(properties, authenticationSchemes) as ChallengeHttpResult;
394
var result =
Results
.Forbid(properties, authenticationSchemes) as ForbidHttpResult;
408
var result =
Results
.InternalServerError(value) as InternalServerError<object>;
422
var result =
Results
.InternalServerError(value) as InternalServerError<Todo>;
433
var result =
Results
.InternalServerError() as InternalServerError;
444
var result =
Results
.SignOut(properties, authenticationSchemes) as SignOutHttpResult;
459
var result =
Results
.SignIn(principal, properties, authenticationSchemes?.First()) as SignInHttpResult;
478
Assert.Throws<ArgumentNullException>("principal", () =>
Results
.SignIn(null));
488
var result =
Results
.Conflict(value) as Conflict<object>;
502
var result =
Results
.Conflict(value) as Conflict<Todo>;
513
var result =
Results
.Conflict() as Conflict;
527
var result =
Results
.Content(content, mediaType) as ContentHttpResult;
544
var result =
Results
.Content(content, contentType, encoding) as ContentHttpResult;
562
var result =
Results
.Content(content, contentType, encoding, statusCode) as ContentHttpResult;
574
var result =
Results
.Created() as Created;
588
var result =
Results
.Created(uri, value) as Created<object>;
604
var result =
Results
.Created(uri, value) as Created<Todo>;
619
var result =
Results
.Created(uri, null) as Created;
634
var result =
Results
.Created(uri, value) as Created<object>;
650
var result =
Results
.Created(uri, value) as Created<Todo>;
665
var result =
Results
.Created(uri, null) as Created;
676
var result =
Results
.Created(default(string), null) as Created;
686
var result =
Results
.Created(string.Empty, null) as Created;
696
var result =
Results
.Created(default(Uri), null) as Created;
709
var result =
Results
.Created(default(string), value) as Created<object>;
723
var result =
Results
.Created(string.Empty, value) as Created<object>;
737
var result =
Results
.Created(default(Uri), value) as Created<object>;
753
var result =
Results
.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<object>;
771
var result =
Results
.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<object>;
786
var result =
Results
.CreatedAtRoute(null, null) as CreatedAtRoute;
800
var result =
Results
.CreatedAtRoute(null, null, null) as CreatedAtRoute;
817
var result =
Results
.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<Todo>;
835
var result =
Results
.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<Todo>;
852
var result =
Results
.CreatedAtRoute(routeName, null, value) as CreatedAtRoute<object>;
869
var result =
Results
.CreatedAtRoute(routeName, null, value) as CreatedAtRoute<Todo>;
884
var result =
Results
.CreatedAtRoute<object>(null, null, null) as CreatedAtRoute;
899
var result =
Results
.CreatedAtRoute(routeName, null, null) as CreatedAtRoute;
911
var result =
Results
.CreatedAtRoute() as CreatedAtRoute;
923
var result =
Results
.Empty as EmptyHttpResult;
939
var result =
Results
.Json(data, options, contentType, statusCode) as JsonHttpResult<object>;
958
var result =
Results
.Json(data, options, contentType, statusCode) as JsonHttpResult<Todo>;
971
var result =
Results
.Json(null) as JsonHttpResult<object>;
984
var result =
Results
.Json(null, StringJsonContext.Default.String as JsonTypeInfo) as JsonHttpResult<object>;
998
var result =
Results
.Json(null, typeof(string), StringJsonContext.Default) as JsonHttpResult<object>;
1012
var result =
Results
.Json(null, StringJsonContext.Default.String) as JsonHttpResult<string>;
1026
var result =
Results
.Json<string>(null, StringJsonContext.Default) as JsonHttpResult<string>;
1039
Assert.Throws<ArgumentNullException>("context", () =>
Results
.Json<object>(null, context: null));
1045
Assert.Throws<ArgumentNullException>("context", () =>
Results
.Json(null, type: typeof(object), context: null));
1051
var ex = Assert.Throws<InvalidOperationException>(() =>
Results
.Json(null, type: typeof(Todo), context: StringJsonContext.Default));
1058
var ex = Assert.Throws<InvalidOperationException>(() =>
Results
.Json<Todo>(null, context: StringJsonContext.Default));
1065
Assert.Throws<ArgumentNullException>("jsonTypeInfo", () =>
Results
.Json(null, jsonTypeInfo: null));
1071
Assert.Throws<ArgumentNullException>("jsonTypeInfo", () =>
Results
.Json<object>(null, jsonTypeInfo: null));
1077
Assert.Throws<ArgumentNullException>("localUrl", () =>
Results
.LocalRedirect(default(string)));
1083
Assert.Throws<ArgumentException>("localUrl", () =>
Results
.LocalRedirect(string.Empty));
1093
var result =
Results
.LocalRedirect(localUrl) as RedirectHttpResult;
1110
var result =
Results
.LocalRedirect(localUrl, permanent) as RedirectHttpResult;
1128
var result =
Results
.LocalRedirect(localUrl, permanent, preserveMethod) as RedirectHttpResult;
1146
var result =
Results
.LocalRedirect(localUrl, permanent, preserveMethod) as RedirectHttpResult;
1159
var result =
Results
.NoContent() as NoContent;
1172
var result =
Results
.NotFound(value) as NotFound<object>;
1186
var result =
Results
.NotFound(value) as NotFound<Todo>;
1197
var result =
Results
.NotFound() as NotFound;
1210
var result =
Results
.Ok(value) as Ok<object>;
1224
var result =
Results
.Ok(value) as Ok<Todo>;
1235
var result =
Results
.Ok() as Ok;
1244
Assert.Throws<ArgumentNullException>("problemDetails", () =>
Results
.Problem(default(ProblemDetails)));
1259
var result =
Results
.Problem(detail, instance, statusCode, title, type, extensions) as ProblemHttpResult;
1283
var result =
Results
.Problem(detail, instance, statusCode, title, type, extensions) as ProblemHttpResult;
1307
var result =
Results
.Problem(detail, instance, statusCode, title, type, extensions) as ProblemHttpResult;
1329
var result =
Results
.Problem(statusCode: statusCode) as ProblemHttpResult;
1345
var result =
Results
.Problem() as ProblemHttpResult;
1364
var result =
Results
.Problem(problem) as ProblemHttpResult;
1380
var result =
Results
.Problem(problem) as ProblemHttpResult;
1392
Assert.Throws<ArgumentNullException>("errors", () =>
Results
.ValidationProblem(default(IDictionary<string, string[]>)));
1411
var result =
Results
.ValidationProblem(errors, detail, instance, statusCode, title, type, extensions) as ProblemHttpResult;
1442
var result =
Results
.ValidationProblem(errors, detail, instance, statusCode, title, type, extensions) as ProblemHttpResult;
1460
Assert.Throws<ArgumentNullException>("url", () =>
Results
.Redirect(default(string)));
1466
Assert.Throws<ArgumentException>("url", () =>
Results
.Redirect(string.Empty));
1476
var result =
Results
.Redirect(url) as RedirectHttpResult;
1492
var result =
Results
.Redirect(url, true) as RedirectHttpResult;
1508
var result =
Results
.Redirect(url, false, true) as RedirectHttpResult;
1526
var result =
Results
.RedirectToRoute(routeName, routeValues, true, true, fragment) as RedirectToRouteHttpResult;
1545
var result =
Results
.RedirectToRoute(routeName, routeValues, true, true, fragment) as RedirectToRouteHttpResult;
1559
var result =
Results
.RedirectToRoute() as RedirectToRouteHttpResult;
1570
var result =
Results
.RedirectToRoute(null, null) as RedirectToRouteHttpResult;
1584
var result =
Results
.StatusCode(statusCode) as StatusCodeHttpResult;
1598
var result =
Results
.Text(content, contentType) as ContentHttpResult;
1614
var result =
Results
.Text(content, contentType) as Utf8ContentHttpResult;
1631
var result =
Results
.Text(content, contentType, statusCode) as Utf8ContentHttpResult;
1648
var result =
Results
.Text(content, contentType, encoding) as ContentHttpResult;
1668
var result =
Results
.Text(content, contentType, encoding, statusCode) as ContentHttpResult;
1682
var result =
Results
.Unauthorized() as UnauthorizedHttpResult;
1692
var result =
Results
.UnprocessableEntity() as UnprocessableEntity;
1710
var actualMethods = new HashSet<string>(typeof(
Results
).GetMethods(BindingFlags.Public | BindingFlags.Static)
1730
(() =>
Results
.Accepted(null, null), typeof(Accepted)),
1731
(() =>
Results
.Accepted(null, new()), typeof(Accepted<object>)),
1732
(() =>
Results
.AcceptedAtRoute("routeName", (object)null, null), typeof(AcceptedAtRoute)),
1733
(() =>
Results
.AcceptedAtRoute("routeName", (object)null, new()), typeof(AcceptedAtRoute<object>)),
1734
(() =>
Results
.AcceptedAtRoute("routeName", null, null), typeof(AcceptedAtRoute)),
1735
(() =>
Results
.AcceptedAtRoute("routeName", null, new()), typeof(AcceptedAtRoute<object>)),
1736
(() =>
Results
.BadRequest(null), typeof(BadRequest)),
1737
(() =>
Results
.BadRequest(new()), typeof(BadRequest<object>)),
1738
(() =>
Results
.Bytes(new byte[0], null, null, false, null, null), typeof(FileContentHttpResult)),
1739
(() =>
Results
.Challenge(null, null), typeof(ChallengeHttpResult)),
1740
(() =>
Results
.Conflict(null), typeof(Conflict)),
1741
(() =>
Results
.Conflict(new()), typeof(Conflict<object>)),
1742
(() =>
Results
.Content("content", null, null), typeof(ContentHttpResult)),
1743
(() =>
Results
.Content("content", null, null, null), typeof(ContentHttpResult)),
1744
(() =>
Results
.Created("/path", null), typeof(Created)),
1745
(() =>
Results
.Created(), typeof(Created)),
1746
(() =>
Results
.Created("/path", new()), typeof(Created<object>)),
1747
(() =>
Results
.CreatedAtRoute("routeName", (object)null, null), typeof(CreatedAtRoute)),
1748
(() =>
Results
.CreatedAtRoute("routeName", (object)null, new()), typeof(CreatedAtRoute<object>)),
1749
(() =>
Results
.CreatedAtRoute("routeName", null, null), typeof(CreatedAtRoute)),
1750
(() =>
Results
.CreatedAtRoute("routeName", null, new()), typeof(CreatedAtRoute<object>)),
1751
(() =>
Results
.Empty, typeof(EmptyHttpResult)),
1752
(() =>
Results
.File(new byte[0], null, null, false, null, null), typeof(FileContentHttpResult)),
1753
(() =>
Results
.File(new MemoryStream(), null, null, null, null, false), typeof(FileStreamHttpResult)),
1754
(() =>
Results
.File(Path.Join(Path.DirectorySeparatorChar.ToString(), "rooted", "path"), null, null, null, null, false), typeof(PhysicalFileHttpResult)),
1755
(() =>
Results
.File("path", null, null, null, null, false), typeof(VirtualFileHttpResult)),
1756
(() =>
Results
.Forbid(null, null), typeof(ForbidHttpResult)),
1757
(() =>
Results
.InternalServerError(), typeof(InternalServerError)),
1758
(() =>
Results
.InternalServerError<object>(new()), typeof(InternalServerError<object>)),
1759
(() =>
Results
.Json(new(), (JsonSerializerOptions)null, null, null), typeof(JsonHttpResult<object>)),
1760
(() =>
Results
.NoContent(), typeof(NoContent)),
1761
(() =>
Results
.NotFound(null), typeof(NotFound)),
1762
(() =>
Results
.NotFound(new()), typeof(NotFound<object>)),
1763
(() =>
Results
.Ok(null), typeof(Ok)),
1764
(() =>
Results
.Ok(new()), typeof(Ok<object>)),
1765
(() =>
Results
.Problem(new()), typeof(ProblemHttpResult)),
1766
(() =>
Results
.Stream(new MemoryStream(), null, null, null, null, false), typeof(FileStreamHttpResult)),
1767
(() =>
Results
.Stream(s => Task.CompletedTask, null, null, null, null), typeof(PushStreamHttpResult)),
1768
(() =>
Results
.Text("content", null, null), typeof(ContentHttpResult)),
1769
(() =>
Results
.Text("content", null, null, null), typeof(ContentHttpResult)),
1770
(() =>
Results
.Redirect("/path", false, false), typeof(RedirectHttpResult)),
1771
(() =>
Results
.LocalRedirect("/path", false, false), typeof(RedirectHttpResult)),
1772
(() =>
Results
.RedirectToRoute("routeName", (object)null, false, false, null), typeof(RedirectToRouteHttpResult)),
1773
(() =>
Results
.RedirectToRoute("routeName", null, false, false, null), typeof(RedirectToRouteHttpResult)),
1774
(() =>
Results
.SignIn(new(), null, null), typeof(SignInHttpResult)),
1775
(() =>
Results
.SignOut(new(), null), typeof(SignOutHttpResult)),
1776
(() =>
Results
.StatusCode(200), typeof(StatusCodeHttpResult)),
1777
(() =>
Results
.Unauthorized(), typeof(UnauthorizedHttpResult)),
1778
(() =>
Results
.UnprocessableEntity(null), typeof(UnprocessableEntity)),
1779
(() =>
Results
.UnprocessableEntity(new()), typeof(UnprocessableEntity<object>)),
1780
(() =>
Results
.ValidationProblem(new Dictionary<string, string[]>(), null, null, null, null, null, null), typeof(ProblemHttpResult))
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (6)
EndpointMetadataApiDescriptionProviderTest.cs (6)
255
() =>
Results
.Ok(new InferredJsonClass()));
360
() => Task.FromResult(
Results
.Ok(new InferredJsonClass())));
1245
builder.MapPost("/file/upload", (IFormFile file) =>
Results
.NoContent());
1273
[Consumes("application/custom0", "application/custom1")] (IFormFile file) =>
Results
.NoContent());
1326
AssertFormFileCollection((IFormFileCollection files) =>
Results
.NoContent(), "files");
1327
AssertFormFileCollection(([FromForm] IFormFileCollection uploads) =>
Results
.NoContent(), "uploads");
Microsoft.AspNetCore.OpenApi.Microbenchmarks (2)
GenerationBenchmarks.cs (2)
35
_builder.MapPost($"/{i}", (Todo todo) =>
Results
.Ok());
36
_builder.MapDelete($"/{i}", (string id) =>
Results
.NoContent());
Microsoft.AspNetCore.OpenApi.Tests (5)
Services\OpenApiGeneratorTests.cs (5)
227
() =>
Results
.Ok(new InferredJsonClass()));
772
var operation = GetOpenApiOperation((IFormFile file) =>
Results
.NoContent());
786
[Consumes("application/custom0", "application/custom1")] (IFormFile file) =>
Results
.NoContent());
839
AssertFormFileCollection((IFormFileCollection files) =>
Results
.NoContent(), "files");
840
AssertFormFileCollection(([FromForm] IFormFileCollection uploads) =>
Results
.NoContent(), "uploads");
Microsoft.AspNetCore.Routing.Tests (1)
Builder\RequestDelegateEndpointRouteBuilderExtensionsTest.cs (1)
257
Assert.Same(
Results
.Empty, response);
MilvusPlayground.ApiService (1)
Program.cs (1)
100
return
Results
.Ok("Collection created");
MinimalFormSample (4)
Program.cs (4)
32
return
Results
.Content(html, "text/html");
49
return
Results
.Content(html, "text/html");
52
app.MapPost("/todo", [ValidateAntiForgeryToken] ([FromForm] Todo todo) =>
Results
.Ok(todo));
60
var result =
Results
.Ok(new Todo(name, isCompleted, dueDate));
MinimalSample (4)
Program.cs (4)
85
"plain" =>
Results
.Problem(statusCode: 500, extensions: extensions),
86
"object" =>
Results
.Problem(new ProblemDetails() { Status = 500, Extensions = { { "traceId", "traceId123" } } }),
87
"validation" =>
Results
.ValidationProblem(errors, statusCode: 400, extensions: extensions),
88
"objectValidation" =>
Results
.Problem(new HttpValidationProblemDetails(errors) { Status = 400, Extensions = { { "traceId", "traceId123" } } }),
MySql.ApiService (5)
Program.cs (5)
39
?
Results
.Ok(item)
40
:
Results
.NotFound();
52
return
Results
.Created($"/catalog/{id}", id);
63
return rows > 0 ?
Results
.NoContent() :
Results
.NotFound();
Nats.ApiService (6)
Program.cs (6)
26
return
Results
.Json(new { rtt, nats.ServerInfo });
33
return
Results
.Created($"/stream/{name}", name);
39
return
Results
.Ok(stream.Info);
51
return
Results
.Problem("Make sure the stream is created before publishing.");
54
return
Results
.Created();
73
return
Results
.Ok(events);
RateLimitingSample (7)
Program.cs (7)
68
?
Results
.Ok(todo)
69
:
Results
.NotFound());
76
return
Results
.Created($"/todoitems/{todo.Id}", todo);
85
return
Results
.NotFound();
93
return
Results
.NoContent();
102
return
Results
.Ok(todo);
105
return
Results
.NotFound();
Sample (10)
EndpointRouteBuilderExtensions.cs (1)
11
return endpoints.MapGet("/swagger/{documentName}", (string documentName) =>
Results
.Content($$"""
Program.cs (9)
57
forms.MapPost("/form-file", (IFormFile resume) =>
Results
.Ok(resume.FileName));
58
forms.MapPost("/form-files", (IFormFileCollection files) =>
Results
.Ok(files.Count));
59
forms.MapPost("/form-file-multiple", (IFormFile resume, IFormFileCollection files) =>
Results
.Ok(files.Count + resume.FileName));
64
forms.MapPost("/form-todo", ([FromForm] Todo todo) =>
Results
.Ok(todo));
65
forms.MapPost("/forms-pocos-and-files", ([FromForm] Todo todo, IFormFile file) =>
Results
.Ok(new { Todo = todo, File = file.FileName }));
79
v1.MapPost("/todos", (Todo todo) =>
Results
.Created($"/todos/{todo.Id}", todo))
87
v2.MapPost("/users", () =>
Results
.Created("/users/1", new { Id = 1, Name = "Test user" }))
103
schemas.MapGet("/iresult-no-produces", () =>
Results
.Ok(new Triangle { Color = "red", Sides = 3, Hypotenuse = 5.0 }));
104
schemas.MapGet("/iresult-with-produces", () =>
Results
.Ok(new Triangle { Color = "red", Sides = 3, Hypotenuse = 5.0 }))
SimpleWebSiteWithWebApplicationBuilder (3)
Program.cs (3)
6
using static Microsoft.AspNetCore.Http.
Results
;
40
app.MapGet("/problem", () =>
Results
.Problem("Some problem"));
47
app.MapPost("/accepts-default", (Person person) =>
Results
.Ok(person.Name));
TestProject.IntegrationServiceA (9)
Postgres\NpgsqlEFCoreExtensions.cs (3)
18
return results.Any() ?
Results
.Ok("Success!") :
Results
.Problem("Failed");
22
return
Results
.Problem(e.ToString());
Postgres\PostgresExtensions.cs (3)
23
return results.HasRows ?
Results
.Ok("Success!") :
Results
.Problem("Failed");
27
return
Results
.Problem(e.ToString());
Redis\RedisExtensions.cs (3)
24
return data == content ?
Results
.Ok("Success!") :
Results
.Problem("Failed");
28
return
Results
.Problem(e.ToString());