263 references to Results
Aspire.Dashboard (7)
DashboardEndpointsBuilder.cs (4)
46return Results.BadRequest(); 53return Results.BadRequest(); 58return Results.BadRequest(); 76return Results.LocalRedirect(redirectUrl);
Otlp\Http\OtlpHttpEndpointsBuilder.cs (3)
47return Results.Empty; 55return Results.Empty; 63return Results.Empty;
Aspire.Dashboard.Tests (6)
Integration\MockOpenIdAuthority.cs (6)
49return Results.Json(new 64return Results.Redirect($"{redirect_uri}?error=interaction_required&state={state}"); 70return Results.Redirect($"{redirect_uri}?error=invalid_request&error_description=extraQueryParams%20not%20preserved&state={state}"); 74return Results.Redirect($"{redirect_uri}?code={lastCode}&state={state}"); 83return Results.BadRequest("Bad code"); 86return Results.Json(new
AzureContainerApps.ApiService (1)
Program.cs (1)
23return Results.Content("""
AzureFunctionsEndToEnd.ApiService (4)
Program.cs (4)
30return Results.Ok("Message sent to Azure Storage Queue."); 49return Results.Ok("String uploaded to Azure Storage Blobs."); 56return Results.Ok("Message sent to Azure EventHubs."); 72return Results.Stream(stream, "application/json");
AzureFunctionsEndToEnd.Functions (1)
MyHttpTrigger.cs (1)
38return 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)
37return Results.NotFound(); 44return Results.NotFound(); 47return Results.File(path, "image/jpeg");
EventHubsApi (2)
Program.cs (2)
20return Results.Ok(); 28return Results.Accepted();
Microsoft.AspNetCore.Http.Extensions.Tests (3)
RequestDelegateFactoryTests.cs (3)
1859IResult actionWithExtensionsResult(string name) => Results.Extensions.TestResult(name); 3100Assert.Same(Results.Empty, response); 3812return Results.Ok(FormattableString.Invariant($"Hello {name}. This is from an extension method."));
Microsoft.AspNetCore.Http.Results.Tests (171)
ResultsTests.cs (171)
31var result = Results.Accepted(uri, value) as Accepted<object>; 47var result = Results.Accepted(uri, value) as Accepted<Todo>; 62var result = Results.Accepted(uri) as Accepted; 73var result = Results.Accepted() as Accepted; 89var result = Results.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<object>; 107var result = Results.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<object>; 122var result = Results.AcceptedAtRoute(null, null) as AcceptedAtRoute; 139var result = Results.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<Todo>; 157var result = Results.AcceptedAtRoute(routeName, routeValues, value) as AcceptedAtRoute<Todo>; 172var result = Results.AcceptedAtRoute<object>(null, null, null) as AcceptedAtRoute; 186var result = Results.AcceptedAtRoute(null, null, null) as AcceptedAtRoute; 202var result = Results.AcceptedAtRoute(routeName, routeValues) as AcceptedAtRoute; 214var result = Results.AcceptedAtRoute() as AcceptedAtRoute; 229var result = Results.BadRequest(value) as BadRequest<object>; 243var result = Results.BadRequest(value) as BadRequest<Todo>; 254var result = Results.BadRequest() as BadRequest; 2700 => Results.Bytes(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag), 271_ => Results.File(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag) 3010 => Results.Stream(stream, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing), 3021 => Results.Stream(PipeReader.Create(stream), contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing), 303_ => Results.Stream((s) => Task.CompletedTask, contentType, fileDownloadName, lastModified, entityTag) 344Assert.Throws<ArgumentNullException>("contents", () => Results.Bytes(null)); 350Assert.Throws<ArgumentNullException>("fileContents", () => Results.File(default(byte[]))); 356Assert.Throws<ArgumentNullException>("fileStream", () => Results.File(default(Stream))); 362Assert.Throws<ArgumentNullException>("stream", () => Results.Stream(default(Stream))); 368Assert.Throws<ArgumentNullException>("pipeReader", () => Results.Stream(default(PipeReader))); 382var result = Results.Challenge(properties, authenticationSchemes) as ChallengeHttpResult; 394var result = Results.Forbid(properties, authenticationSchemes) as ForbidHttpResult; 408var result = Results.InternalServerError(value) as InternalServerError<object>; 422var result = Results.InternalServerError(value) as InternalServerError<Todo>; 433var result = Results.InternalServerError() as InternalServerError; 444var result = Results.SignOut(properties, authenticationSchemes) as SignOutHttpResult; 459var result = Results.SignIn(principal, properties, authenticationSchemes?.First()) as SignInHttpResult; 478Assert.Throws<ArgumentNullException>("principal", () => Results.SignIn(null)); 488var result = Results.Conflict(value) as Conflict<object>; 502var result = Results.Conflict(value) as Conflict<Todo>; 513var result = Results.Conflict() as Conflict; 527var result = Results.Content(content, mediaType) as ContentHttpResult; 544var result = Results.Content(content, contentType, encoding) as ContentHttpResult; 562var result = Results.Content(content, contentType, encoding, statusCode) as ContentHttpResult; 574var result = Results.Created() as Created; 588var result = Results.Created(uri, value) as Created<object>; 604var result = Results.Created(uri, value) as Created<Todo>; 619var result = Results.Created(uri, null) as Created; 634var result = Results.Created(uri, value) as Created<object>; 650var result = Results.Created(uri, value) as Created<Todo>; 665var result = Results.Created(uri, null) as Created; 676var result = Results.Created(default(string), null) as Created; 686var result = Results.Created(string.Empty, null) as Created; 696var result = Results.Created(default(Uri), null) as Created; 709var result = Results.Created(default(string), value) as Created<object>; 723var result = Results.Created(string.Empty, value) as Created<object>; 737var result = Results.Created(default(Uri), value) as Created<object>; 753var result = Results.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<object>; 771var result = Results.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<object>; 786var result = Results.CreatedAtRoute(null, null) as CreatedAtRoute; 800var result = Results.CreatedAtRoute(null, null, null) as CreatedAtRoute; 817var result = Results.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<Todo>; 835var result = Results.CreatedAtRoute(routeName, routeValues, value) as CreatedAtRoute<Todo>; 852var result = Results.CreatedAtRoute(routeName, null, value) as CreatedAtRoute<object>; 869var result = Results.CreatedAtRoute(routeName, null, value) as CreatedAtRoute<Todo>; 884var result = Results.CreatedAtRoute<object>(null, null, null) as CreatedAtRoute; 899var result = Results.CreatedAtRoute(routeName, null, null) as CreatedAtRoute; 911var result = Results.CreatedAtRoute() as CreatedAtRoute; 923var result = Results.Empty as EmptyHttpResult; 939var result = Results.Json(data, options, contentType, statusCode) as JsonHttpResult<object>; 958var result = Results.Json(data, options, contentType, statusCode) as JsonHttpResult<Todo>; 971var result = Results.Json(null) as JsonHttpResult<object>; 984var result = Results.Json(null, StringJsonContext.Default.String as JsonTypeInfo) as JsonHttpResult<object>; 998var result = Results.Json(null, typeof(string), StringJsonContext.Default) as JsonHttpResult<object>; 1012var result = Results.Json(null, StringJsonContext.Default.String) as JsonHttpResult<string>; 1026var result = Results.Json<string>(null, StringJsonContext.Default) as JsonHttpResult<string>; 1039Assert.Throws<ArgumentNullException>("context", () => Results.Json<object>(null, context: null)); 1045Assert.Throws<ArgumentNullException>("context", () => Results.Json(null, type: typeof(object), context: null)); 1051var ex = Assert.Throws<InvalidOperationException>(() => Results.Json(null, type: typeof(Todo), context: StringJsonContext.Default)); 1058var ex = Assert.Throws<InvalidOperationException>(() => Results.Json<Todo>(null, context: StringJsonContext.Default)); 1065Assert.Throws<ArgumentNullException>("jsonTypeInfo", () => Results.Json(null, jsonTypeInfo: null)); 1071Assert.Throws<ArgumentNullException>("jsonTypeInfo", () => Results.Json<object>(null, jsonTypeInfo: null)); 1077Assert.Throws<ArgumentNullException>("localUrl", () => Results.LocalRedirect(default(string))); 1083Assert.Throws<ArgumentException>("localUrl", () => Results.LocalRedirect(string.Empty)); 1093var result = Results.LocalRedirect(localUrl) as RedirectHttpResult; 1110var result = Results.LocalRedirect(localUrl, permanent) as RedirectHttpResult; 1128var result = Results.LocalRedirect(localUrl, permanent, preserveMethod) as RedirectHttpResult; 1146var result = Results.LocalRedirect(localUrl, permanent, preserveMethod) as RedirectHttpResult; 1159var result = Results.NoContent() as NoContent; 1172var result = Results.NotFound(value) as NotFound<object>; 1186var result = Results.NotFound(value) as NotFound<Todo>; 1197var result = Results.NotFound() as NotFound; 1210var result = Results.Ok(value) as Ok<object>; 1224var result = Results.Ok(value) as Ok<Todo>; 1235var result = Results.Ok() as Ok; 1244Assert.Throws<ArgumentNullException>("problemDetails", () => Results.Problem(default(ProblemDetails))); 1259var result = Results.Problem(detail, instance, statusCode, title, type, extensions) as ProblemHttpResult; 1283var result = Results.Problem(detail, instance, statusCode, title, type, extensions) as ProblemHttpResult; 1307var result = Results.Problem(detail, instance, statusCode, title, type, extensions) as ProblemHttpResult; 1329var result = Results.Problem(statusCode: statusCode) as ProblemHttpResult; 1345var result = Results.Problem() as ProblemHttpResult; 1364var result = Results.Problem(problem) as ProblemHttpResult; 1380var result = Results.Problem(problem) as ProblemHttpResult; 1392Assert.Throws<ArgumentNullException>("errors", () => Results.ValidationProblem(default(IDictionary<string, string[]>))); 1411var result = Results.ValidationProblem(errors, detail, instance, statusCode, title, type, extensions) as ProblemHttpResult; 1442var result = Results.ValidationProblem(errors, detail, instance, statusCode, title, type, extensions) as ProblemHttpResult; 1460Assert.Throws<ArgumentNullException>("url", () => Results.Redirect(default(string))); 1466Assert.Throws<ArgumentException>("url", () => Results.Redirect(string.Empty)); 1476var result = Results.Redirect(url) as RedirectHttpResult; 1492var result = Results.Redirect(url, true) as RedirectHttpResult; 1508var result = Results.Redirect(url, false, true) as RedirectHttpResult; 1526var result = Results.RedirectToRoute(routeName, routeValues, true, true, fragment) as RedirectToRouteHttpResult; 1545var result = Results.RedirectToRoute(routeName, routeValues, true, true, fragment) as RedirectToRouteHttpResult; 1559var result = Results.RedirectToRoute() as RedirectToRouteHttpResult; 1570var result = Results.RedirectToRoute(null, null) as RedirectToRouteHttpResult; 1584var result = Results.StatusCode(statusCode) as StatusCodeHttpResult; 1598var result = Results.Text(content, contentType) as ContentHttpResult; 1614var result = Results.Text(content, contentType) as Utf8ContentHttpResult; 1631var result = Results.Text(content, contentType, statusCode) as Utf8ContentHttpResult; 1648var result = Results.Text(content, contentType, encoding) as ContentHttpResult; 1668var result = Results.Text(content, contentType, encoding, statusCode) as ContentHttpResult; 1682var result = Results.Unauthorized() as UnauthorizedHttpResult; 1692var result = Results.UnprocessableEntity() as UnprocessableEntity; 1710var 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()))); 1245builder.MapPost("/file/upload", (IFormFile file) => Results.NoContent()); 1273[Consumes("application/custom0", "application/custom1")] (IFormFile file) => Results.NoContent()); 1326AssertFormFileCollection((IFormFileCollection files) => Results.NoContent(), "files"); 1327AssertFormFileCollection(([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())); 772var operation = GetOpenApiOperation((IFormFile file) => Results.NoContent()); 786[Consumes("application/custom0", "application/custom1")] (IFormFile file) => Results.NoContent()); 839AssertFormFileCollection((IFormFileCollection files) => Results.NoContent(), "files"); 840AssertFormFileCollection(([FromForm] IFormFileCollection uploads) => Results.NoContent(), "uploads");
Microsoft.AspNetCore.Routing.Tests (1)
Builder\RequestDelegateEndpointRouteBuilderExtensionsTest.cs (1)
257Assert.Same(Results.Empty, response);
MilvusPlayground.ApiService (1)
Program.cs (1)
100return Results.Ok("Collection created");
MinimalFormSample (4)
Program.cs (4)
32return Results.Content(html, "text/html"); 49return Results.Content(html, "text/html"); 52app.MapPost("/todo", [ValidateAntiForgeryToken] ([FromForm] Todo todo) => Results.Ok(todo)); 60var 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(); 52return Results.Created($"/catalog/{id}", id); 63return rows > 0 ? Results.NoContent() : Results.NotFound();
Nats.ApiService (6)
Program.cs (6)
26return Results.Json(new { rtt, nats.ServerInfo }); 33return Results.Created($"/stream/{name}", name); 39return Results.Ok(stream.Info); 51return Results.Problem("Make sure the stream is created before publishing."); 54return Results.Created(); 73return Results.Ok(events);
RateLimitingSample (7)
Program.cs (7)
68? Results.Ok(todo) 69: Results.NotFound()); 76return Results.Created($"/todoitems/{todo.Id}", todo); 85return Results.NotFound(); 93return Results.NoContent(); 102return Results.Ok(todo); 105return Results.NotFound();
Sample (10)
EndpointRouteBuilderExtensions.cs (1)
11return endpoints.MapGet("/swagger/{documentName}", (string documentName) => Results.Content($$"""
Program.cs (9)
57forms.MapPost("/form-file", (IFormFile resume) => Results.Ok(resume.FileName)); 58forms.MapPost("/form-files", (IFormFileCollection files) => Results.Ok(files.Count)); 59forms.MapPost("/form-file-multiple", (IFormFile resume, IFormFileCollection files) => Results.Ok(files.Count + resume.FileName)); 64forms.MapPost("/form-todo", ([FromForm] Todo todo) => Results.Ok(todo)); 65forms.MapPost("/forms-pocos-and-files", ([FromForm] Todo todo, IFormFile file) => Results.Ok(new { Todo = todo, File = file.FileName })); 79v1.MapPost("/todos", (Todo todo) => Results.Created($"/todos/{todo.Id}", todo)) 87v2.MapPost("/users", () => Results.Created("/users/1", new { Id = 1, Name = "Test user" })) 103schemas.MapGet("/iresult-no-produces", () => Results.Ok(new Triangle { Color = "red", Sides = 3, Hypotenuse = 5.0 })); 104schemas.MapGet("/iresult-with-produces", () => Results.Ok(new Triangle { Color = "red", Sides = 3, Hypotenuse = 5.0 }))
SimpleWebSiteWithWebApplicationBuilder (3)
Program.cs (3)
6using static Microsoft.AspNetCore.Http.Results; 40app.MapGet("/problem", () => Results.Problem("Some problem")); 47app.MapPost("/accepts-default", (Person person) => Results.Ok(person.Name));
TestProject.IntegrationServiceA (9)
Postgres\NpgsqlEFCoreExtensions.cs (3)
18return results.Any() ? Results.Ok("Success!") : Results.Problem("Failed"); 22return Results.Problem(e.ToString());
Postgres\PostgresExtensions.cs (3)
23return results.HasRows ? Results.Ok("Success!") : Results.Problem("Failed"); 27return Results.Problem(e.ToString());
Redis\RedisExtensions.cs (3)
24return data == content ? Results.Ok("Success!") : Results.Problem("Failed"); 28return Results.Problem(e.ToString());