216 references to TypedResults
Aspire.Dashboard (1)
DashboardWebApplication.cs (1)
433
_app.MapPost("/authentication/logout", () =>
TypedResults
.SignOut(authenticationSchemes: [CookieAuthenticationDefaults.AuthenticationScheme, OpenIdConnectDefaults.AuthenticationScheme]));
Keycloak.Web (2)
LoginLogoutEndpointRouteBuilderExtensions.cs (2)
13
group.MapGet("/login", () =>
TypedResults
.Challenge(new AuthenticationProperties { RedirectUri = "/" }))
16
group.MapPost("/logout", () =>
TypedResults
.SignOut(new AuthenticationProperties { RedirectUri = "/" },
Microsoft.AspNetCore.Http.Results (59)
Results.cs (59)
41
=>
TypedResults
.Challenge(properties, authenticationSchemes);
59
=>
TypedResults
.Forbid(properties, authenticationSchemes);
72
=>
TypedResults
.SignIn(principal, properties, authenticationScheme);
81
=>
TypedResults
.SignOut(properties, authenticationSchemes);
116
=>
TypedResults
.Content(content, contentType, contentEncoding, statusCode);
151
=>
TypedResults
.Text(content, contentType, contentEncoding, statusCode);
161
=>
TypedResults
.Text(utf8Content, contentType, statusCode);
170
=>
TypedResults
.Content(content, contentType);
243
=>
TypedResults
.Json(data, options, contentType, statusCode);
259
=>
TypedResults
.Json(data, jsonTypeInfo, contentType, statusCode);
275
=>
TypedResults
.Json(data, context, contentType, statusCode);
300
=>
TypedResults
.File(fileContents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag);
325
=>
TypedResults
.Bytes(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag);
348
=>
TypedResults
.Bytes(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag);
379
=>
TypedResults
.File(fileStream, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing);
410
=>
TypedResults
.Stream(stream, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing);
438
=>
TypedResults
.Stream(pipeReader, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing);
457
=>
TypedResults
.Stream(streamWriterCallback, contentType, fileDownloadName, lastModified, entityTag);
481
?
TypedResults
.PhysicalFile(path, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing)
482
:
TypedResults
.VirtualFile(path, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing);
506
=>
TypedResults
.Redirect(url, permanent, preserveMethod);
530
=>
TypedResults
.LocalRedirect(localUrl, permanent, preserveMethod);
557
=>
TypedResults
.RedirectToRoute(routeName, routeValues, permanent, preserveMethod, fragment);
585
=>
TypedResults
.RedirectToRoute(routeName, routeValues, permanent, preserveMethod, fragment);
593
=>
TypedResults
.StatusCode(statusCode);
609
=> value is null ?
TypedResults
.NotFound() :
TypedResults
.NotFound(value);
616
=>
TypedResults
.Unauthorized();
632
=> error is null ?
TypedResults
.BadRequest() :
TypedResults
.BadRequest(error);
648
=> error is null ?
TypedResults
.Conflict() :
TypedResults
.Conflict(error);
655
=>
TypedResults
.NoContent();
671
=> value is null ?
TypedResults
.Ok() :
TypedResults
.Ok(value);
687
=> error is null ?
TypedResults
.UnprocessableEntity() :
TypedResults
.UnprocessableEntity(error);
702
=> error is null ?
TypedResults
.InternalServerError() :
TypedResults
.InternalServerError(error);
721
=>
TypedResults
.Problem(detail, instance, statusCode, title, type, extensions);
742
=>
TypedResults
.Problem(detail, instance, statusCode, title, type, extensions);
750
=>
TypedResults
.Problem(problemDetails);
814
return
TypedResults
.Problem(problemDetails);
833
=>
TypedResults
.Created();
851
=> value is null ?
TypedResults
.Created(uri) :
TypedResults
.Created(uri, value);
869
=> value is null ?
TypedResults
.Created(uri) :
TypedResults
.Created(uri, value);
903
=> value is null ?
TypedResults
.CreatedAtRoute(routeName, routeValues) :
TypedResults
.CreatedAtRoute(value, routeName, routeValues);
915
=> value is null ?
TypedResults
.CreatedAtRoute(routeName, routeValues) :
TypedResults
.CreatedAtRoute(value, routeName, routeValues);
933
=> value is null ?
TypedResults
.Accepted(uri) :
TypedResults
.Accepted(uri, value);
967
=> value is null ?
TypedResults
.AcceptedAtRoute(routeName, routeValues) :
TypedResults
.AcceptedAtRoute(value, routeName, routeValues);
979
=> value is null ?
TypedResults
.AcceptedAtRoute(routeName, routeValues) :
TypedResults
.AcceptedAtRoute(value, routeName, routeValues);
984
public static IResult Empty { get; } =
TypedResults
.Empty;
Microsoft.AspNetCore.Http.Results.Tests (111)
ResultsTests.cs (1)
374
Assert.Throws<ArgumentNullException>("streamWriterCallback", () =>
TypedResults
.Stream(default(Func<Stream, Task>)));
TypedResultsTests.cs (110)
30
var result =
TypedResults
.Accepted(uri, value);
45
var result =
TypedResults
.Accepted(uri);
59
var result =
TypedResults
.Accepted(uri);
74
var result =
TypedResults
.Accepted(uri, value);
89
var result =
TypedResults
.Accepted(uri);
99
Assert.Throws<ArgumentNullException>("uri", () =>
TypedResults
.Accepted(default(Uri)));
105
Assert.Throws<ArgumentNullException>("uri", () =>
TypedResults
.Accepted(default(Uri), default(object)));
117
var result =
TypedResults
.AcceptedAtRoute(value, routeName, routeValues);
134
var result =
TypedResults
.AcceptedAtRoute(routeName, routeValues);
148
var result =
TypedResults
.AcceptedAtRoute(null, null);
162
var result =
TypedResults
.AcceptedAtRoute<object>(null, null, null);
174
var result =
TypedResults
.AcceptedAtRoute();
189
var result =
TypedResults
.AcceptedAtRoute(routeValues: routeValues);
205
var result =
TypedResults
.AcceptedAtRoute(value: value, routeValues: routeValues);
221
var result =
TypedResults
.BadRequest(value);
232
var result =
TypedResults
.BadRequest();
248
0 =>
TypedResults
.Bytes(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag),
249
_ =>
TypedResults
.File(contents, contentType, fileDownloadName, enableRangeProcessing, lastModified, entityTag)
277
var result =
TypedResults
.PhysicalFile(path, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing);
296
var result =
TypedResults
.VirtualFile(path, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing);
318
Assert.Throws<ArgumentNullException>("contents", () =>
TypedResults
.Bytes(null));
324
Assert.Throws<ArgumentNullException>("fileContents", () =>
TypedResults
.File(default(byte[])));
330
Assert.Throws<ArgumentNullException>("fileStream", () =>
TypedResults
.File(default(Stream)));
336
Assert.Throws<ArgumentNullException>("stream", () =>
TypedResults
.Stream(default(Stream)));
342
Assert.Throws<ArgumentNullException>("pipeReader", () =>
TypedResults
.Stream(default(PipeReader)));
348
Assert.Throws<ArgumentNullException>("streamWriterCallback", () =>
TypedResults
.Stream(default(Func<Stream, Task>)));
354
Assert.Throws<ArgumentNullException>("path", () =>
TypedResults
.PhysicalFile(default(string)));
360
Assert.Throws<ArgumentException>("path", () =>
TypedResults
.PhysicalFile(string.Empty));
366
Assert.Throws<ArgumentNullException>("path", () =>
TypedResults
.VirtualFile(default(string)));
372
Assert.Throws<ArgumentException>("path", () =>
TypedResults
.VirtualFile(string.Empty));
385
0 =>
TypedResults
.Stream(stream, contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing),
386
1 =>
TypedResults
.Stream(PipeReader.Create(stream), contentType, fileDownloadName, lastModified, entityTag, enableRangeProcessing),
387
_ => (IResult)
TypedResults
.Stream((s) => Task.CompletedTask, contentType, fileDownloadName, lastModified, entityTag)
430
var result =
TypedResults
.Challenge(properties, authenticationSchemes);
442
var result =
TypedResults
.Forbid(properties, authenticationSchemes);
454
var result =
TypedResults
.SignOut(properties, authenticationSchemes);
469
var result =
TypedResults
.SignIn(principal, properties, authenticationSchemes?.First());
488
Assert.Throws<ArgumentNullException>("principal", () =>
TypedResults
.SignIn(null));
498
var result =
TypedResults
.Conflict(value);
509
var result =
TypedResults
.Conflict();
523
var result =
TypedResults
.Content(content, mediaType);
540
var result =
TypedResults
.Content(content, contentType, encoding);
558
var result =
TypedResults
.Content(content, contentType, encoding, statusCode);
570
var result =
TypedResults
.Created();
585
var result =
TypedResults
.Created(uri, value);
600
var result =
TypedResults
.Created(uri);
615
var result =
TypedResults
.Created(uri, value);
630
var result =
TypedResults
.Created(uri);
641
var result =
TypedResults
.Created(default(string));
650
var result =
TypedResults
.Created(string.Empty);
658
var result =
TypedResults
.Created(default(Uri));
666
var result =
TypedResults
.Created(default(string), default(object));
676
var result =
TypedResults
.Created(string.Empty, default(object));
686
var result =
TypedResults
.Created(default(Uri), default(object));
701
var result =
TypedResults
.CreatedAtRoute(value, routeName, routeValues);
718
var result =
TypedResults
.CreatedAtRoute(value, routeName, null);
734
var result =
TypedResults
.CreatedAtRoute(routeName, default(object));
746
var result =
TypedResults
.CreatedAtRoute();
761
var result =
TypedResults
.CreatedAtRoute(routeValues: routeValues);
777
var result =
TypedResults
.CreatedAtRoute(value: value, routeValues: routeValues);
792
var result =
TypedResults
.CreatedAtRoute(null, null);
806
var result =
TypedResults
.CreatedAtRoute<object>(null, null, null);
818
var result =
TypedResults
.Empty;
834
var result =
TypedResults
.Json(data, options, contentType, statusCode);
850
var result =
TypedResults
.Json(data);
866
var result =
TypedResults
.Json(data, ObjectJsonContext.Default.Object);
883
var result =
TypedResults
.Json(data, ObjectJsonContext.Default);
899
Assert.Throws<ArgumentNullException>("context", () =>
TypedResults
.Json(data, context: null));
905
var ex = Assert.Throws<InvalidOperationException>(() =>
TypedResults
.Json(string.Empty, context: ObjectJsonContext.Default));
915
Assert.Throws<ArgumentNullException>("jsonTypeInfo", () =>
TypedResults
.Json(data, jsonTypeInfo: null));
921
Assert.Throws<ArgumentNullException>("localUrl", () =>
TypedResults
.LocalRedirect(default(string)));
927
Assert.Throws<ArgumentException>("localUrl", () =>
TypedResults
.LocalRedirect(string.Empty));
937
var result =
TypedResults
.LocalRedirect(localUrl);
954
var result =
TypedResults
.LocalRedirect(localUrl, permanent);
972
var result =
TypedResults
.LocalRedirect(localUrl, permanent, preserveMethod);
990
var result =
TypedResults
.LocalRedirect(localUrl, permanent, preserveMethod);
1003
var result =
TypedResults
.NoContent();
1016
var result =
TypedResults
.NotFound(value);
1027
var result =
TypedResults
.NotFound();
1040
var result =
TypedResults
.Ok(value);
1051
var result =
TypedResults
.Ok();
1060
Assert.Throws<ArgumentNullException>("problemDetails", () =>
TypedResults
.Problem(default(ProblemDetails)));
1075
var result =
TypedResults
.Problem(detail, instance, statusCode, title, type, extensions);
1099
var result =
TypedResults
.Problem(detail, instance, statusCode, title, type, extensions);
1120
var result =
TypedResults
.Problem(statusCode: statusCode);
1137
var result =
TypedResults
.Problem();
1156
var result =
TypedResults
.Problem(problem);
1172
var result =
TypedResults
.Problem(problem);
1184
Assert.Throws<ArgumentNullException>("errors", () =>
TypedResults
.ValidationProblem(default(IDictionary<string, string[]>)));
1199
var result =
TypedResults
.ValidationProblem(errors, detail, instance, title, type, extensions);
1225
var result =
TypedResults
.ValidationProblem(errors, detail, instance, title, type, extensions);
1242
Assert.Throws<ArgumentNullException>("url", () =>
TypedResults
.Redirect(default(string)));
1248
Assert.Throws<ArgumentException>("url", () =>
TypedResults
.Redirect(string.Empty));
1258
var result =
TypedResults
.Redirect(url);
1274
var result =
TypedResults
.Redirect(url, true);
1290
var result =
TypedResults
.Redirect(url, false, true);
1308
var result =
TypedResults
.RedirectToRoute(routeName, routeValues, true, true, fragment);
1322
var result =
TypedResults
.RedirectToRoute();
1336
var result =
TypedResults
.RedirectToRoute(routeValues: routeValues);
1349
var result =
TypedResults
.RedirectToRoute(null, null);
1363
var result =
TypedResults
.StatusCode(statusCode);
1377
var result =
TypedResults
.Text(content, contentType);
1393
var result =
TypedResults
.Text(content, contentType);
1410
var result =
TypedResults
.Text(content, contentType, statusCode);
1427
var result =
TypedResults
.Text(content, contentType, encoding);
1447
var result =
TypedResults
.Text(content, contentType, encoding, statusCode);
1461
var result =
TypedResults
.Unauthorized();
1471
var result =
TypedResults
.UnprocessableEntity();
1484
var result =
TypedResults
.InternalServerError(value);
1495
var result =
TypedResults
.InternalServerError();
Microsoft.AspNetCore.Identity (21)
IdentityApiEndpointRouteBuilderExtensions.cs (21)
87
return
TypedResults
.Ok();
115
return
TypedResults
.Problem(result.ToString(), statusCode: StatusCodes.Status401Unauthorized);
119
return
TypedResults
.Empty;
135
return
TypedResults
.Challenge();
139
return
TypedResults
.SignIn(newPrincipal, authenticationScheme: IdentityConstants.BearerScheme);
149
return
TypedResults
.Unauthorized();
158
return
TypedResults
.Unauthorized();
181
return
TypedResults
.Unauthorized();
184
return
TypedResults
.Text("Thank you for confirming your email.");
199
return
TypedResults
.Ok();
203
return
TypedResults
.Ok();
222
return
TypedResults
.Ok();
255
return
TypedResults
.Ok();
267
return
TypedResults
.NotFound();
326
return
TypedResults
.Ok(new TwoFactorResponse
342
return
TypedResults
.NotFound();
345
return
TypedResults
.Ok(await CreateInfoResponseAsync(user, userManager));
354
return
TypedResults
.NotFound();
387
return
TypedResults
.Ok(await CreateInfoResponseAsync(user, userManager));
425
TypedResults
.ValidationProblem(new Dictionary<string, string[]> {
454
return
TypedResults
.ValidationProblem(errorDictionary);
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (6)
EndpointMetadataApiDescriptionProviderTest.cs (6)
281
TypedResults
.Created("https://example.com", new InferredJsonClass()));
306
var apiDescription = GetApiDescription(() =>
TypedResults
.Created("https://example.com", new InferredJsonClass()));
324
var apiDescription = GetApiDescription(() =>
TypedResults
.Problem());
339
Task.FromResult(
TypedResults
.Created("https://example.com", new InferredJsonClass())));
392
?
TypedResults
.Created<InferredJsonClass>("/", new InferredJsonClass())
393
:
TypedResults
.Problem();
Microsoft.AspNetCore.OpenApi.Tests (6)
Services\OpenApiGeneratorTests.cs (1)
873
var operation = GetOpenApiOperation(() =>
TypedResults
.Ok(new InferredJsonClass()),
Services\OpenApiSchemaService\OpenApiSchemaService.ResponseSchemas.cs (4)
384
builder.MapGet("/api", () =>
TypedResults
.Created("/test/1", new { Id = 1, Name = "Test", Todo = new Todo(1, "Test", true, DateTime.Now) }));
447
builder.MapGet("/", () =>
TypedResults
.Ok<List<Todo>>([new Todo(1, "Test Title", true, DateTime.Now), new Todo(2, "Test Title 2", false, DateTime.Now)]));
494
builder.MapGet("/", () =>
TypedResults
.Ok<PaginatedItems<Todo>>(new(0, 1, 5, 50, [new Todo(1, "Test Title", true, DateTime.Now), new Todo(2, "Test Title 2", false, DateTime.Now)])));
574
builder.MapGet("/", () =>
TypedResults
.ValidationProblem(new Dictionary<string, string[]>
Transformers\Implementations\OpenApiSchemaReferenceTransformerTests.cs (1)
73
builder.MapPost("/api", (Todo todo) =>
TypedResults
.Ok(todo));
MinimalSample (5)
Program.cs (5)
74
<= 0 =>
TypedResults
.BadRequest(),
75
>= 1 and <= 10 =>
TypedResults
.Ok(new Todo(id, "Walk the dog")),
76
_ =>
TypedResults
.NotFound()
89
"validationTyped" =>
TypedResults
.ValidationProblem(errors, extensions: extensions),
90
_ =>
TypedResults
.NotFound()
Sample (5)
Program.cs (5)
98
schemas.MapGet("/typed-results", () =>
TypedResults
.Ok(new Triangle { Color = "red", Sides = 3, Hypotenuse = 5.0 }));
100
?
TypedResults
.Ok(new Triangle { Color = "red", Sides = 3, Hypotenuse = 5.0 })
101
:
TypedResults
.NotFound<string>("Item not found."));
106
schemas.MapGet("/product", (Product product) =>
TypedResults
.Ok(product));
107
schemas.MapGet("/account", (Account account) =>
TypedResults
.Ok(account));