diff --git a/src/Http/Http.Results/src/AcceptedAtRouteHttpResult.cs b/src/Http/Http.Results/src/AcceptedAtRouteHttpResult.cs
index 0e45e84164ce..ebfade39293d 100644
--- a/src/Http/Http.Results/src/AcceptedAtRouteHttpResult.cs
+++ b/src/Http/Http.Results/src/AcceptedAtRouteHttpResult.cs
@@ -15,17 +15,6 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed class AcceptedAtRouteHttpResult : IResult
{
- ///
- /// Initializes a new instance of the class with the values
- /// provided.
- ///
- /// The route data to use for generating the URL.
- /// The value to format in the entity body.
- internal AcceptedAtRouteHttpResult(object? routeValues, object? value)
- : this(routeName: null, routeValues: routeValues, value: value)
- {
- }
-
///
/// Initializes a new instance of the class with the values
/// provided.
@@ -33,10 +22,10 @@ internal AcceptedAtRouteHttpResult(object? routeValues, object? value)
/// The name of the route to use for generating the URL.
/// The route data to use for generating the URL.
/// The value to format in the entity body.
- internal AcceptedAtRouteHttpResult(
- string? routeName,
- object? routeValues,
- object? value)
+ public AcceptedAtRouteHttpResult(
+ string? routeName = null,
+ object? routeValues = null,
+ object? value = null)
{
Value = value;
RouteName = routeName;
diff --git a/src/Http/Http.Results/src/AcceptedHttpResult.cs b/src/Http/Http.Results/src/AcceptedHttpResult.cs
index d0b6026e0c56..9173f3c28c57 100644
--- a/src/Http/Http.Results/src/AcceptedHttpResult.cs
+++ b/src/Http/Http.Results/src/AcceptedHttpResult.cs
@@ -20,7 +20,9 @@ public sealed class AcceptedHttpResult : IResult
///
/// The location at which the status of requested content can be monitored.
/// The value to format in the entity body.
- internal AcceptedHttpResult(string? location, object? value)
+#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
+ public AcceptedHttpResult(string? location, object? value = null)
+#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
Location = location;
@@ -33,7 +35,9 @@ internal AcceptedHttpResult(string? location, object? value)
///
/// The location at which the status of requested content can be monitored.
/// The value to format in the entity body.
- internal AcceptedHttpResult(Uri locationUri, object? value)
+#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
+ public AcceptedHttpResult(Uri locationUri, object? value = null)
+#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
diff --git a/src/Http/Http.Results/src/BadRequestObjectHttpResult.cs b/src/Http/Http.Results/src/BadRequestObjectHttpResult.cs
index dc9ad6e4fb2f..9c3646af7cc8 100644
--- a/src/Http/Http.Results/src/BadRequestObjectHttpResult.cs
+++ b/src/Http/Http.Results/src/BadRequestObjectHttpResult.cs
@@ -17,7 +17,7 @@ public sealed class BadRequestObjectHttpResult : IResult
/// provided.
///
/// The error content to format in the entity body.
- internal BadRequestObjectHttpResult(object? error)
+ public BadRequestObjectHttpResult(object? error = null)
{
Value = error;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
@@ -26,7 +26,7 @@ internal BadRequestObjectHttpResult(object? error)
///
/// Gets the object result.
///
- public object? Value { get; internal init; }
+ public object? Value { get; }
///
/// Gets the HTTP status code.
diff --git a/src/Http/Http.Results/src/ChallengeHttpResult.cs b/src/Http/Http.Results/src/ChallengeHttpResult.cs
index cff6c06937dd..b901e62e40ed 100644
--- a/src/Http/Http.Results/src/ChallengeHttpResult.cs
+++ b/src/Http/Http.Results/src/ChallengeHttpResult.cs
@@ -13,42 +13,16 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed partial class ChallengeHttpResult : IResult
{
- ///
- /// Initializes a new instance of .
- ///
- internal ChallengeHttpResult()
- : this(Array.Empty())
- {
- }
-
- ///
- /// Initializes a new instance of with the
- /// specified authentication scheme.
- ///
- /// The authentication scheme to challenge.
- internal ChallengeHttpResult(string authenticationScheme)
- : this(new[] { authenticationScheme })
- {
- }
-
- ///
- /// Initializes a new instance of with the
- /// specified authentication schemes.
- ///
- /// The authentication schemes to challenge.
- internal ChallengeHttpResult(IList authenticationSchemes)
- : this(authenticationSchemes, properties: null)
- {
- }
-
///
/// Initializes a new instance of with the
/// specified .
///
/// used to perform the authentication
/// challenge.
- internal ChallengeHttpResult(AuthenticationProperties? properties)
- : this(Array.Empty(), properties)
+#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
+ public ChallengeHttpResult(AuthenticationProperties? properties = null)
+#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
+ : this(properties, authenticationSchemes: Array.Empty())
{
}
@@ -59,8 +33,8 @@ internal ChallengeHttpResult(AuthenticationProperties? properties)
/// The authentication schemes to challenge.
/// used to perform the authentication
/// challenge.
- internal ChallengeHttpResult(string authenticationScheme, AuthenticationProperties? properties)
- : this(new[] { authenticationScheme }, properties)
+ public ChallengeHttpResult(AuthenticationProperties? properties, string authenticationScheme)
+ : this(properties, authenticationSchemes: new[] { authenticationScheme })
{
}
@@ -71,7 +45,7 @@ internal ChallengeHttpResult(string authenticationScheme, AuthenticationProperti
/// The authentication scheme to challenge.
/// used to perform the authentication
/// challenge.
- internal ChallengeHttpResult(IList authenticationSchemes, AuthenticationProperties? properties)
+ public ChallengeHttpResult(AuthenticationProperties? properties, IList authenticationSchemes)
{
AuthenticationSchemes = authenticationSchemes.AsReadOnly();
Properties = properties;
@@ -80,12 +54,12 @@ internal ChallengeHttpResult(IList authenticationSchemes, Authentication
///
/// Gets the authentication schemes that are challenged.
///
- public IReadOnlyList AuthenticationSchemes { get; internal init; } = Array.Empty();
+ public IReadOnlyList AuthenticationSchemes { get; }
///
/// Gets the used to perform the sign-out operation.
///
- public AuthenticationProperties? Properties { get; internal init; }
+ public AuthenticationProperties? Properties { get; }
///
public async Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/ConflictObjectHttpResult.cs b/src/Http/Http.Results/src/ConflictObjectHttpResult.cs
index 782775395bfc..a09b05d7512f 100644
--- a/src/Http/Http.Results/src/ConflictObjectHttpResult.cs
+++ b/src/Http/Http.Results/src/ConflictObjectHttpResult.cs
@@ -17,7 +17,7 @@ public sealed class ConflictObjectHttpResult : IResult
/// provided.
///
/// The error content to format in the entity body.
- internal ConflictObjectHttpResult(object? error)
+ public ConflictObjectHttpResult(object? error = null)
{
Value = error;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
@@ -26,7 +26,7 @@ internal ConflictObjectHttpResult(object? error)
///
/// Gets the object result.
///
- public object? Value { get; internal init; }
+ public object? Value { get; }
///
/// Gets the HTTP status code.
diff --git a/src/Http/Http.Results/src/ContentHttpResult.cs b/src/Http/Http.Results/src/ContentHttpResult.cs
index a50675408e2d..32ef30d67b18 100644
--- a/src/Http/Http.Results/src/ContentHttpResult.cs
+++ b/src/Http/Http.Results/src/ContentHttpResult.cs
@@ -12,43 +12,31 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed partial class ContentHttpResult : IResult
{
- ///
- /// Initializes a new instance of the class with the values.
- ///
- /// The value to format in the entity body.
- /// The Content-Type header for the response
- internal ContentHttpResult(string? content, string? contentType)
- : this(content, contentType, statusCode: null)
- {
- }
-
///
/// Initializes a new instance of the class with the values
///
/// The value to format in the entity body.
- /// The HTTP status code of the response.
/// The Content-Type header for the response
- internal ContentHttpResult(string? content, string? contentType, int? statusCode)
+ public ContentHttpResult(string? content = null, string? contentType = null)
{
Content = content;
- StatusCode = statusCode;
ContentType = contentType;
}
///
/// Gets or set the content representing the body of the response.
///
- public string? Content { get; internal init; }
+ public string? Content { get; }
///
/// Gets or sets the Content-Type header for the response.
///
- public string? ContentType { get; internal init; }
+ public string? ContentType { get; }
///
/// Gets the HTTP status code.
///
- public int? StatusCode { get; internal init; }
+ public int? StatusCode { get; init; }
///
/// Writes the content to the HTTP response.
diff --git a/src/Http/Http.Results/src/CreatedAtRouteHttpResult.cs b/src/Http/Http.Results/src/CreatedAtRouteHttpResult.cs
index f59593be8505..7ccc35c7e1a3 100644
--- a/src/Http/Http.Results/src/CreatedAtRouteHttpResult.cs
+++ b/src/Http/Http.Results/src/CreatedAtRouteHttpResult.cs
@@ -14,17 +14,6 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed class CreatedAtRouteHttpResult : IResult
{
- ///
- /// Initializes a new instance of the class with the values
- /// provided.
- ///
- /// The route data to use for generating the URL.
- /// The value to format in the entity body.
- internal CreatedAtRouteHttpResult(object? routeValues, object? value)
- : this(routeName: null, routeValues: routeValues, value: value)
- {
- }
-
///
/// Initializes a new instance of the class with the values
/// provided.
@@ -32,10 +21,10 @@ internal CreatedAtRouteHttpResult(object? routeValues, object? value)
/// The name of the route to use for generating the URL.
/// The route data to use for generating the URL.
/// The value to format in the entity body.
- internal CreatedAtRouteHttpResult(
- string? routeName,
- object? routeValues,
- object? value)
+ public CreatedAtRouteHttpResult(
+ string? routeName = null,
+ object? routeValues = null,
+ object? value = null)
{
Value = value;
RouteName = routeName;
diff --git a/src/Http/Http.Results/src/CreatedHttpResult.cs b/src/Http/Http.Results/src/CreatedHttpResult.cs
index 4106cacd7fec..d3c719e1f699 100644
--- a/src/Http/Http.Results/src/CreatedHttpResult.cs
+++ b/src/Http/Http.Results/src/CreatedHttpResult.cs
@@ -16,9 +16,11 @@ public sealed class CreatedHttpResult : IResult
/// Initializes a new instance of the class with the values
/// provided.
///
- /// The location at which the content has been created.
+ /// The location at which the status of requested content can be monitored.
/// The value to format in the entity body.
- internal CreatedHttpResult(string location, object? value)
+#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
+ public CreatedHttpResult(string? location, object? value = null)
+#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
Location = location;
@@ -29,9 +31,11 @@ internal CreatedHttpResult(string location, object? value)
/// Initializes a new instance of the class with the values
/// provided.
///
- /// The location at which the content has been created.
+ /// The location at which the status of requested content can be monitored.
/// The value to format in the entity body.
- internal CreatedHttpResult(Uri locationUri, object? value)
+#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
+ public CreatedHttpResult(Uri locationUri, object? value = null)
+#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
diff --git a/src/Http/Http.Results/src/EmptyHttpResult.cs b/src/Http/Http.Results/src/EmptyHttpResult.cs
index 9e9b25c166dd..8f5e4544fd25 100644
--- a/src/Http/Http.Results/src/EmptyHttpResult.cs
+++ b/src/Http/Http.Results/src/EmptyHttpResult.cs
@@ -9,15 +9,6 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed class EmptyHttpResult : IResult
{
- private EmptyHttpResult()
- {
- }
-
- ///
- /// Gets an instance of .
- ///
- public static EmptyHttpResult Instance { get; } = new();
-
///
public Task ExecuteAsync(HttpContext httpContext)
{
diff --git a/src/Http/Http.Results/src/FileContentHttpResult.cs b/src/Http/Http.Results/src/FileContentHttpResult.cs
index 56cd17d13944..9a333dd98d8e 100644
--- a/src/Http/Http.Results/src/FileContentHttpResult.cs
+++ b/src/Http/Http.Results/src/FileContentHttpResult.cs
@@ -14,94 +14,52 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed partial class FileContentHttpResult : IResult
{
- ///
- /// Creates a new instance with
- /// the provided and the
- /// provided .
- ///
- /// The bytes that represent the file contents.
- /// The Content-Type of the file.
- internal FileContentHttpResult(ReadOnlyMemory fileContents, string? contentType)
- : this(fileContents, contentType, fileDownloadName: null)
- {
- }
-
- ///
- /// Creates a new instance with
- /// the provided , the provided
- /// and the provided .
- ///
- /// The bytes that represent the file contents.
- /// The Content-Type header of the response.
- /// The suggested file name.
- internal FileContentHttpResult(
- ReadOnlyMemory fileContents,
- string? contentType,
- string? fileDownloadName)
- : this(fileContents, contentType, fileDownloadName, enableRangeProcessing: false)
- {
- }
-
///
/// Creates a new instance with the provided values.
///
/// The bytes that represent the file contents.
- /// The Content-Type of the file.
- /// The suggested file name.
- /// Set to true to enable range requests processing.
- /// The of when the file was last modified.
- /// The associated with the file.
- internal FileContentHttpResult(
- ReadOnlyMemory fileContents,
- string? contentType,
- string? fileDownloadName,
- bool enableRangeProcessing,
- DateTimeOffset? lastModified = null,
- EntityTagHeaderValue? entityTag = null)
+ /// The Content-Type header of the response.
+ public FileContentHttpResult(ReadOnlyMemory fileContents, string? contentType = null)
{
FileContents = fileContents;
FileLength = fileContents.Length;
ContentType = contentType ?? "application/octet-stream";
- FileDownloadName = fileDownloadName;
- EnableRangeProcessing = enableRangeProcessing;
- LastModified = lastModified;
- EntityTag = entityTag;
}
///
- /// Gets the Content-Type header for the response.
+ /// Gets the file contents.
///
- public string ContentType { get; internal set; }
+ public ReadOnlyMemory FileContents { get; }
///
- /// Gets the file name that will be used in the Content-Disposition header of the response.
+ /// Gets the file length information .
///
- public string? FileDownloadName { get; internal set; }
+ public long? FileLength { get; }
///
- /// Gets the last modified information associated with the file result.
+ /// Gets the Content-Type header for the response.
///
- public DateTimeOffset? LastModified { get; internal set; }
+ public string ContentType { get; }
///
- /// Gets the etag associated with the file result.
+ /// Gets the value that enables range processing for the file result.
///
- public EntityTagHeaderValue? EntityTag { get; internal init; }
+ public bool EnableRangeProcessing { get; init; }
///
- /// Gets the value that enables range processing for the file result.
+ /// Gets the etag associated with the file result.
///
- public bool EnableRangeProcessing { get; internal init; }
+ public EntityTagHeaderValue? EntityTag { get; init; }
///
- /// Gets or sets the file length information .
+ /// Gets the file name that will be used in the Content-Disposition header of the response.
///
- public long? FileLength { get; internal set; }
+ public string? FileDownloadName { get; init; }
///
- /// Gets or sets the file contents.
+ /// Gets the last modified information associated with the file result.
///
- public ReadOnlyMemory FileContents { get; internal init; }
+ public DateTimeOffset? LastModified { get; init; }
///
public Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/FileStreamHttpResult.cs b/src/Http/Http.Results/src/FileStreamHttpResult.cs
index 4a2273c535f0..848d0fa8518c 100644
--- a/src/Http/Http.Results/src/FileStreamHttpResult.cs
+++ b/src/Http/Http.Results/src/FileStreamHttpResult.cs
@@ -14,50 +14,12 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed class FileStreamHttpResult : IResult
{
- ///
- /// Creates a new instance with
- /// the provided and the
- /// provided .
- ///
- /// The stream with the file.
- /// The Content-Type of the file.
- internal FileStreamHttpResult(Stream fileStream, string? contentType)
- : this(fileStream, contentType, fileDownloadName: null)
- {
- }
-
- ///
- /// Creates a new instance with
- /// the provided , the provided
- /// and the provided .
- ///
- /// The stream with the file.
- /// The Content-Type header of the response.
- /// The suggested file name.
- internal FileStreamHttpResult(
- Stream fileStream,
- string? contentType,
- string? fileDownloadName)
- : this(fileStream, contentType, fileDownloadName, enableRangeProcessing: false)
- {
- }
-
///
/// Creates a new instance with the provided values.
///
/// The stream with the file.
- /// The Content-Type of the file.
- /// The suggested file name.
- /// Set to true to enable range requests processing.
- /// The of when the file was last modified.
- /// The associated with the file.
- internal FileStreamHttpResult(
- Stream fileStream,
- string? contentType,
- string? fileDownloadName,
- bool enableRangeProcessing,
- DateTimeOffset? lastModified = null,
- EntityTagHeaderValue? entityTag = null)
+ /// The Content-Type header of the response.
+ public FileStreamHttpResult(Stream fileStream, string? contentType = null)
{
if (fileStream == null)
{
@@ -71,46 +33,42 @@ internal FileStreamHttpResult(
}
ContentType = contentType ?? "application/octet-stream";
- FileDownloadName = fileDownloadName;
- EnableRangeProcessing = enableRangeProcessing;
- LastModified = lastModified;
- EntityTag = entityTag;
}
///
- /// Gets the Content-Type header for the response.
+ /// Gets or sets the stream with the file that will be sent back as the response.
///
- public string ContentType { get; internal set; }
+ public Stream FileStream { get; }
///
- /// Gets the file name that will be used in the Content-Disposition header of the response.
+ /// Gets or sets the file length information .
///
- public string? FileDownloadName { get; internal set; }
+ public long? FileLength { get; }
///
- /// Gets the last modified information associated with the file result.
+ /// Gets the Content-Type header for the response.
///
- public DateTimeOffset? LastModified { get; internal set; }
+ public string ContentType { get; }
///
- /// Gets the etag associated with the file result.
+ /// Gets the value that enables range processing for the file result.
///
- public EntityTagHeaderValue? EntityTag { get; internal init; }
+ public bool EnableRangeProcessing { get; init; }
///
- /// Gets the value that enables range processing for the file result.
+ /// Gets the etag associated with the file result.
///
- public bool EnableRangeProcessing { get; internal init; }
+ public EntityTagHeaderValue? EntityTag { get; init; }
///
- /// Gets or sets the file length information .
+ /// Gets the file name that will be used in the Content-Disposition header of the response.
///
- public long? FileLength { get; internal set; }
+ public string? FileDownloadName { get; init; }
///
- /// Gets or sets the stream with the file that will be sent back as the response.
+ /// Gets the last modified information associated with the file result.
///
- public Stream FileStream { get; }
+ public DateTimeOffset? LastModified { get; init; }
///
public async Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/ForbidHttpResult.cs b/src/Http/Http.Results/src/ForbidHttpResult.cs
index f9d8d9c27897..c32f04e8fb4a 100644
--- a/src/Http/Http.Results/src/ForbidHttpResult.cs
+++ b/src/Http/Http.Results/src/ForbidHttpResult.cs
@@ -13,42 +13,16 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed partial class ForbidHttpResult : IResult
{
- ///
- /// Initializes a new instance of .
- ///
- internal ForbidHttpResult()
- : this(Array.Empty())
- {
- }
-
- ///
- /// Initializes a new instance of with the
- /// specified authentication scheme.
- ///
- /// The authentication scheme to challenge.
- internal ForbidHttpResult(string authenticationScheme)
- : this(new[] { authenticationScheme })
- {
- }
-
- ///
- /// Initializes a new instance of with the
- /// specified authentication schemes.
- ///
- /// The authentication schemes to challenge.
- internal ForbidHttpResult(IList authenticationSchemes)
- : this(authenticationSchemes, properties: null)
- {
- }
-
///
/// Initializes a new instance of with the
/// specified .
///
/// used to perform the authentication
/// challenge.
- internal ForbidHttpResult(AuthenticationProperties? properties)
- : this(Array.Empty(), properties)
+#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
+ public ForbidHttpResult(AuthenticationProperties? properties = null)
+#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
+ : this(properties, authenticationSchemes: Array.Empty())
{
}
@@ -59,8 +33,8 @@ internal ForbidHttpResult(AuthenticationProperties? properties)
/// The authentication schemes to challenge.
/// used to perform the authentication
/// challenge.
- internal ForbidHttpResult(string authenticationScheme, AuthenticationProperties? properties)
- : this(new[] { authenticationScheme }, properties)
+ public ForbidHttpResult(AuthenticationProperties? properties, string authenticationScheme)
+ : this(properties, authenticationSchemes: new[] { authenticationScheme })
{
}
@@ -71,7 +45,7 @@ internal ForbidHttpResult(string authenticationScheme, AuthenticationProperties?
/// The authentication scheme to challenge.
/// used to perform the authentication
/// challenge.
- internal ForbidHttpResult(IList authenticationSchemes, AuthenticationProperties? properties)
+ public ForbidHttpResult(AuthenticationProperties? properties, IList authenticationSchemes)
{
AuthenticationSchemes = authenticationSchemes.AsReadOnly();
Properties = properties;
@@ -80,12 +54,12 @@ internal ForbidHttpResult(IList authenticationSchemes, AuthenticationPro
///
/// Gets the authentication schemes that are challenged.
///
- public IReadOnlyList AuthenticationSchemes { get; internal init; }
+ public IReadOnlyList AuthenticationSchemes { get; }
///
/// Gets the used to perform the authentication challenge.
///
- public AuthenticationProperties? Properties { get; internal init; }
+ public AuthenticationProperties? Properties { get; }
///
public async Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/JsonHttpResult.cs b/src/Http/Http.Results/src/JsonHttpResult.cs
index 1e7800a32bdb..5cc12be56d53 100644
--- a/src/Http/Http.Results/src/JsonHttpResult.cs
+++ b/src/Http/Http.Results/src/JsonHttpResult.cs
@@ -12,74 +12,48 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed class JsonHttpResult : IResult
{
- ///
- /// Initializes a new instance of the class with the values.
- ///
- /// The value to format in the entity body.
- /// The serializer settings.
- internal JsonHttpResult(object? value, JsonSerializerOptions? jsonSerializerOptions)
- : this(value, statusCode: null, contentType: null, jsonSerializerOptions: jsonSerializerOptions)
- {
- }
+ private int? _statusCode;
///
/// Initializes a new instance of the class with the values.
///
/// The value to format in the entity body.
- /// The HTTP status code of the response.
/// The serializer settings.
- internal JsonHttpResult(object? value, int? statusCode, JsonSerializerOptions? jsonSerializerOptions)
- : this(value, statusCode: statusCode, contentType: null, jsonSerializerOptions: jsonSerializerOptions)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the values.
- ///
- /// The value to format in the entity body.
- /// The value for the Content-Type header
- /// The serializer settings.
- internal JsonHttpResult(object? value, string? contentType, JsonSerializerOptions? jsonSerializerOptions)
- : this(value, statusCode: null, contentType: contentType, jsonSerializerOptions: jsonSerializerOptions)
- {
-
- }
-
- ///
- /// Initializes a new instance of the class with the values.
- ///
- /// The value to format in the entity body.
- /// The HTTP status code of the response.
- /// The serializer settings.
- /// The value for the Content-Type header
- internal JsonHttpResult(object? value, int? statusCode, string? contentType, JsonSerializerOptions? jsonSerializerOptions)
+ public JsonHttpResult(object? value = null, JsonSerializerOptions? jsonSerializerOptions = null)
{
Value = value;
- StatusCode = statusCode;
JsonSerializerOptions = jsonSerializerOptions;
- ContentType = contentType;
- HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
+
+ HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, statusCode: null);
}
///
- /// Gets or sets the serializer settings.
+ /// Gets the object result.
///
- public JsonSerializerOptions? JsonSerializerOptions { get; internal init; }
+ public object? Value { get; }
///
- /// Gets the object result.
+ /// Gets or sets the serializer settings.
///
- public object? Value { get; }
+ public JsonSerializerOptions? JsonSerializerOptions { get; }
///
/// Gets the value for the Content-Type header.
///
- public string? ContentType { get; internal set; }
+ public string? ContentType { get; init; }
///
/// Gets the HTTP status code.
///
- public int? StatusCode { get; }
+ public int? StatusCode
+ {
+ get => _statusCode;
+ init
+ {
+ _statusCode = value;
+ HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, _statusCode);
+ }
+ }
///
public Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj b/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj
index cfa2eb2e0da9..3e8f0911c68e 100644
--- a/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj
+++ b/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj
@@ -28,4 +28,21 @@
+
+
+
+
+
+
+ True
+ True
+ KnownStatusCodeHttpResults.tt
+
+
+ True
+ True
+ StatusCodeHttpResult.Cache.tt
+
+
+
diff --git a/src/Http/Http.Results/src/NoContentHttpResult.cs b/src/Http/Http.Results/src/NoContentHttpResult.cs
index 0339cc3f1f38..078e7db2b948 100644
--- a/src/Http/Http.Results/src/NoContentHttpResult.cs
+++ b/src/Http/Http.Results/src/NoContentHttpResult.cs
@@ -12,13 +12,6 @@ namespace Microsoft.AspNetCore.Http;
///
public class NoContentHttpResult : IResult
{
- ///
- /// Initializes a new instance of the class.
- ///
- internal NoContentHttpResult()
- {
- }
-
///
/// Gets the HTTP status code.
///
diff --git a/src/Http/Http.Results/src/NotFoundObjectHttpResult.cs b/src/Http/Http.Results/src/NotFoundObjectHttpResult.cs
index 45220b7d0483..02560a93e2ce 100644
--- a/src/Http/Http.Results/src/NotFoundObjectHttpResult.cs
+++ b/src/Http/Http.Results/src/NotFoundObjectHttpResult.cs
@@ -16,7 +16,7 @@ public sealed class NotFoundObjectHttpResult : IResult
/// Initializes a new instance of the class with the values.
///
/// The value to format in the entity body.
- internal NotFoundObjectHttpResult(object? value)
+ public NotFoundObjectHttpResult(object? value = null)
{
Value = value;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
@@ -25,7 +25,7 @@ internal NotFoundObjectHttpResult(object? value)
///
/// Gets the object result.
///
- public object? Value { get; internal init; }
+ public object? Value { get; }
///
/// Gets the HTTP status code.
diff --git a/src/Http/Http.Results/src/ObjectHttpResult.cs b/src/Http/Http.Results/src/ObjectHttpResult.cs
index 252ab122a1da..e57965b02c6c 100644
--- a/src/Http/Http.Results/src/ObjectHttpResult.cs
+++ b/src/Http/Http.Results/src/ObjectHttpResult.cs
@@ -12,56 +12,50 @@ namespace Microsoft.AspNetCore.Http;
///
internal sealed class ObjectHttpResult : IResult
{
- ///
- /// Creates a new instance
- /// with the provided .
- ///
- internal ObjectHttpResult(object? value)
- : this(value, null)
- {
- }
-
///
/// Creates a new instance with the provided
- /// , .
+ /// .
///
- internal ObjectHttpResult(object? value, int? statusCode)
- : this(value, statusCode, contentType: null)
+ public ObjectHttpResult(object? value)
{
+ Value = value;
+
+ if (value is ProblemDetails problemDetails)
+ {
+ HttpResultsHelper.ApplyProblemDetailsDefaults(problemDetails, null);
+ StatusCode = problemDetails.Status;
+ }
}
///
/// Creates a new instance with the provided
- /// , and .
+ /// , .
///
- internal ObjectHttpResult(object? value, int? statusCode, string? contentType)
+ public ObjectHttpResult(object? value, int statusCode)
{
Value = value;
+ StatusCode = statusCode;
if (value is ProblemDetails problemDetails)
{
HttpResultsHelper.ApplyProblemDetailsDefaults(problemDetails, statusCode);
- statusCode ??= problemDetails.Status;
}
-
- StatusCode = statusCode;
- ContentType = contentType;
}
///
/// Gets the object result.
///
- public object? Value { get; internal init; }
+ public object? Value { get; }
///
- /// Gets or sets the value for the Content-Type header.
+ /// Gets the HTTP status code.
///
- public string? ContentType { get; internal init; }
+ public int? StatusCode { get; }
///
- /// Gets the HTTP status code.
+ /// Gets or sets the value for the Content-Type header.
///
- public int? StatusCode { get; internal init; }
+ public string? ContentType { get; init; }
///
public Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/OkObjectHttpResult.cs b/src/Http/Http.Results/src/OkObjectHttpResult.cs
index 2dedc139d7ab..bfb671fd9c4a 100644
--- a/src/Http/Http.Results/src/OkObjectHttpResult.cs
+++ b/src/Http/Http.Results/src/OkObjectHttpResult.cs
@@ -17,7 +17,7 @@ public sealed class OkObjectHttpResult : IResult
/// Initializes a new instance of the class with the values.
///
/// The value to format in the entity body.
- internal OkObjectHttpResult(object? value)
+ public OkObjectHttpResult(object? value = null)
{
Value = value;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
@@ -26,7 +26,7 @@ internal OkObjectHttpResult(object? value)
///
/// Gets the object result.
///
- public object? Value { get; internal init; }
+ public object? Value { get; }
///
/// Gets the HTTP status code.
diff --git a/src/Http/Http.Results/src/PhysicalFileHttpResult.cs b/src/Http/Http.Results/src/PhysicalFileHttpResult.cs
index 97f8e01dca38..b2e857932e33 100644
--- a/src/Http/Http.Results/src/PhysicalFileHttpResult.cs
+++ b/src/Http/Http.Results/src/PhysicalFileHttpResult.cs
@@ -13,92 +13,57 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed partial class PhysicalFileHttpResult : IResult
{
- ///
- /// Creates a new instance with
- /// the provided and the provided .
- ///
- /// The path to the file. The path must be an absolute path.
- /// The Content-Type header of the response.
- internal PhysicalFileHttpResult(string fileName, string? contentType)
- : this(fileName, contentType, fileDownloadName: null)
- {
- }
-
- ///
- /// Creates a new instance with
- /// the provided , the provided
- /// and the provided .
- ///
- /// The path to the file. The path must be an absolute path.
- /// The Content-Type header of the response.
- /// The suggested file name.
- internal PhysicalFileHttpResult(
- string fileName,
- string? contentType,
- string? fileDownloadName)
- : this(fileName, contentType, fileDownloadName, enableRangeProcessing: false)
- {
- }
+ private DateTimeOffset? _lastModified;
///
/// Creates a new instance with the provided values.
///
/// The path to the file. The path must be an absolute path.
/// The Content-Type header of the response.
- /// The suggested file name.
- /// Set to true to enable range requests processing.
- /// The of when the file was last modified.
- /// The associated with the file.
- internal PhysicalFileHttpResult(
- string fileName,
- string? contentType,
- string? fileDownloadName,
- bool enableRangeProcessing,
- DateTimeOffset? lastModified = null,
- EntityTagHeaderValue? entityTag = null)
+ public PhysicalFileHttpResult(string fileName, string? contentType = null)
{
- FileName = fileName;
+ FileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
ContentType = contentType ?? "application/octet-stream";
- FileDownloadName = fileDownloadName;
- EnableRangeProcessing = enableRangeProcessing;
- LastModified = lastModified;
- EntityTag = entityTag;
}
///
- /// Gets the Content-Type header for the response.
+ /// Gets or sets the path to the file that will be sent back as the response.
///
- public string ContentType { get; internal set; }
+ public string FileName { get; }
///
- /// Gets the file name that will be used in the Content-Disposition header of the response.
+ /// Gets or sets the file length information .
///
- public string? FileDownloadName { get; internal set; }
+ public long? FileLength { get; private set; }
///
- /// Gets the last modified information associated with the file result.
+ /// Gets the Content-Type header for the response.
///
- public DateTimeOffset? LastModified { get; internal set; }
+ public string ContentType { get; }
///
- /// Gets the etag associated with the file result.
+ /// Gets the value that enables range processing for the file result.
///
- public EntityTagHeaderValue? EntityTag { get; internal init; }
+ public bool EnableRangeProcessing { get; init; }
///
- /// Gets the value that enables range processing for the file result.
+ /// Gets the etag associated with the file result.
///
- public bool EnableRangeProcessing { get; internal init; }
+ public EntityTagHeaderValue? EntityTag { get; init; }
///
- /// Gets or sets the file length information .
+ /// Gets the file name that will be used in the Content-Disposition header of the response.
///
- public long? FileLength { get; internal set; }
+ public string? FileDownloadName { get; init; }
///
- /// Gets or sets the path to the file that will be sent back as the response.
+ /// Gets the last modified information associated with the file result.
///
- public string FileName { get; }
+ public DateTimeOffset? LastModified
+ {
+ get => _lastModified;
+ init => _lastModified = value;
+ }
// For testing
internal Func GetFileInfoWrapper { get; init; } =
@@ -113,7 +78,7 @@ public Task ExecuteAsync(HttpContext httpContext)
throw new FileNotFoundException($"Could not find file: {FileName}", FileName);
}
- LastModified ??= fileInfo.LastWriteTimeUtc;
+ _lastModified ??= fileInfo.LastWriteTimeUtc;
FileLength = fileInfo.Length;
// Creating the logger with a string to preserve the category after the refactoring.
diff --git a/src/Http/Http.Results/src/ProblemHttpResult.cs b/src/Http/Http.Results/src/ProblemHttpResult.cs
index 0a5c52a0fcca..affb6cf9415f 100644
--- a/src/Http/Http.Results/src/ProblemHttpResult.cs
+++ b/src/Http/Http.Results/src/ProblemHttpResult.cs
@@ -18,12 +18,51 @@ public sealed class ProblemHttpResult : IResult
/// the provided .
///
/// The instance to format in the entity body.
- internal ProblemHttpResult(ProblemDetails problemDetails)
+ public ProblemHttpResult(ProblemDetails problemDetails)
{
ProblemDetails = problemDetails;
HttpResultsHelper.ApplyProblemDetailsDefaults(ProblemDetails, statusCode: null);
}
+ ///
+ /// Creates a new instance with
+ /// the provided values.
+ ///
+ /// The value for .
+ /// The value for .
+ /// The value for .
+ /// The value for .
+ /// The value for .
+ /// The value for .
+ /// The created for the response.
+ public ProblemHttpResult(
+ string? detail = null,
+ string? instance = null,
+ int? statusCode = null,
+ string? title = null,
+ string? type = null,
+ IDictionary? extensions = null)
+ {
+ ProblemDetails = new ProblemDetails
+ {
+ Detail = detail,
+ Instance = instance,
+ Status = statusCode,
+ Title = title,
+ Type = type,
+ };
+
+ if (extensions is not null)
+ {
+ foreach (var extension in extensions)
+ {
+ ProblemDetails.Extensions.Add(extension);
+ }
+ }
+
+ HttpResultsHelper.ApplyProblemDetailsDefaults(ProblemDetails, statusCode: null);
+ }
+
///
/// Gets the instance.
///
diff --git a/src/Http/Http.Results/src/PublicAPI.Unshipped.txt b/src/Http/Http.Results/src/PublicAPI.Unshipped.txt
index b53f85370ac8..12b910829063 100644
--- a/src/Http/Http.Results/src/PublicAPI.Unshipped.txt
+++ b/src/Http/Http.Results/src/PublicAPI.Unshipped.txt
@@ -1,148 +1,214 @@
#nullable enable
Microsoft.AspNetCore.Http.AcceptedAtRouteHttpResult
+Microsoft.AspNetCore.Http.AcceptedAtRouteHttpResult.AcceptedAtRouteHttpResult(string? routeName = null, object? routeValues = null, object? value = null) -> void
Microsoft.AspNetCore.Http.AcceptedAtRouteHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.AcceptedAtRouteHttpResult.RouteName.get -> string?
Microsoft.AspNetCore.Http.AcceptedAtRouteHttpResult.RouteValues.get -> Microsoft.AspNetCore.Routing.RouteValueDictionary!
Microsoft.AspNetCore.Http.AcceptedAtRouteHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.AcceptedAtRouteHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.AcceptedHttpResult
+Microsoft.AspNetCore.Http.AcceptedHttpResult.AcceptedHttpResult(System.Uri! locationUri, object? value = null) -> void
+Microsoft.AspNetCore.Http.AcceptedHttpResult.AcceptedHttpResult(string? location, object? value = null) -> void
Microsoft.AspNetCore.Http.AcceptedHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.AcceptedHttpResult.Location.get -> string?
Microsoft.AspNetCore.Http.AcceptedHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.AcceptedHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.BadRequestObjectHttpResult
+Microsoft.AspNetCore.Http.BadRequestObjectHttpResult.BadRequestObjectHttpResult(object? error = null) -> void
Microsoft.AspNetCore.Http.BadRequestObjectHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.BadRequestObjectHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.BadRequestObjectHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.ChallengeHttpResult
Microsoft.AspNetCore.Http.ChallengeHttpResult.AuthenticationSchemes.get -> System.Collections.Generic.IReadOnlyList!
+Microsoft.AspNetCore.Http.ChallengeHttpResult.ChallengeHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties = null) -> void
+Microsoft.AspNetCore.Http.ChallengeHttpResult.ChallengeHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties, System.Collections.Generic.IList! authenticationSchemes) -> void
+Microsoft.AspNetCore.Http.ChallengeHttpResult.ChallengeHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties, string! authenticationScheme) -> void
Microsoft.AspNetCore.Http.ChallengeHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.ChallengeHttpResult.Properties.get -> Microsoft.AspNetCore.Authentication.AuthenticationProperties?
Microsoft.AspNetCore.Http.ConflictObjectHttpResult
+Microsoft.AspNetCore.Http.ConflictObjectHttpResult.ConflictObjectHttpResult(object? error = null) -> void
Microsoft.AspNetCore.Http.ConflictObjectHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.ConflictObjectHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.ConflictObjectHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.ContentHttpResult
Microsoft.AspNetCore.Http.ContentHttpResult.Content.get -> string?
+Microsoft.AspNetCore.Http.ContentHttpResult.ContentHttpResult(string? content = null, string? contentType = null) -> void
Microsoft.AspNetCore.Http.ContentHttpResult.ContentType.get -> string?
Microsoft.AspNetCore.Http.ContentHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.ContentHttpResult.StatusCode.get -> int?
+Microsoft.AspNetCore.Http.ContentHttpResult.StatusCode.init -> void
Microsoft.AspNetCore.Http.CreatedAtRouteHttpResult
+Microsoft.AspNetCore.Http.CreatedAtRouteHttpResult.CreatedAtRouteHttpResult(string? routeName = null, object? routeValues = null, object? value = null) -> void
Microsoft.AspNetCore.Http.CreatedAtRouteHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.CreatedAtRouteHttpResult.RouteName.get -> string?
Microsoft.AspNetCore.Http.CreatedAtRouteHttpResult.RouteValues.get -> Microsoft.AspNetCore.Routing.RouteValueDictionary?
Microsoft.AspNetCore.Http.CreatedAtRouteHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.CreatedAtRouteHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.CreatedHttpResult
+Microsoft.AspNetCore.Http.CreatedHttpResult.CreatedHttpResult(System.Uri! locationUri, object? value = null) -> void
+Microsoft.AspNetCore.Http.CreatedHttpResult.CreatedHttpResult(string? location, object? value = null) -> void
Microsoft.AspNetCore.Http.CreatedHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.CreatedHttpResult.Location.get -> string?
Microsoft.AspNetCore.Http.CreatedHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.CreatedHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.EmptyHttpResult
+Microsoft.AspNetCore.Http.EmptyHttpResult.EmptyHttpResult() -> void
Microsoft.AspNetCore.Http.EmptyHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.FileContentHttpResult
Microsoft.AspNetCore.Http.FileContentHttpResult.ContentType.get -> string!
Microsoft.AspNetCore.Http.FileContentHttpResult.EnableRangeProcessing.get -> bool
+Microsoft.AspNetCore.Http.FileContentHttpResult.EnableRangeProcessing.init -> void
Microsoft.AspNetCore.Http.FileContentHttpResult.EntityTag.get -> Microsoft.Net.Http.Headers.EntityTagHeaderValue?
+Microsoft.AspNetCore.Http.FileContentHttpResult.EntityTag.init -> void
Microsoft.AspNetCore.Http.FileContentHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
+Microsoft.AspNetCore.Http.FileContentHttpResult.FileContentHttpResult(System.ReadOnlyMemory fileContents, string? contentType = null) -> void
Microsoft.AspNetCore.Http.FileContentHttpResult.FileContents.get -> System.ReadOnlyMemory
Microsoft.AspNetCore.Http.FileContentHttpResult.FileDownloadName.get -> string?
+Microsoft.AspNetCore.Http.FileContentHttpResult.FileDownloadName.init -> void
Microsoft.AspNetCore.Http.FileContentHttpResult.FileLength.get -> long?
Microsoft.AspNetCore.Http.FileContentHttpResult.LastModified.get -> System.DateTimeOffset?
+Microsoft.AspNetCore.Http.FileContentHttpResult.LastModified.init -> void
Microsoft.AspNetCore.Http.FileStreamHttpResult
Microsoft.AspNetCore.Http.FileStreamHttpResult.ContentType.get -> string!
Microsoft.AspNetCore.Http.FileStreamHttpResult.EnableRangeProcessing.get -> bool
+Microsoft.AspNetCore.Http.FileStreamHttpResult.EnableRangeProcessing.init -> void
Microsoft.AspNetCore.Http.FileStreamHttpResult.EntityTag.get -> Microsoft.Net.Http.Headers.EntityTagHeaderValue?
+Microsoft.AspNetCore.Http.FileStreamHttpResult.EntityTag.init -> void
Microsoft.AspNetCore.Http.FileStreamHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.FileStreamHttpResult.FileDownloadName.get -> string?
+Microsoft.AspNetCore.Http.FileStreamHttpResult.FileDownloadName.init -> void
Microsoft.AspNetCore.Http.FileStreamHttpResult.FileLength.get -> long?
Microsoft.AspNetCore.Http.FileStreamHttpResult.FileStream.get -> System.IO.Stream!
+Microsoft.AspNetCore.Http.FileStreamHttpResult.FileStreamHttpResult(System.IO.Stream! fileStream, string? contentType = null) -> void
Microsoft.AspNetCore.Http.FileStreamHttpResult.LastModified.get -> System.DateTimeOffset?
+Microsoft.AspNetCore.Http.FileStreamHttpResult.LastModified.init -> void
Microsoft.AspNetCore.Http.ForbidHttpResult
Microsoft.AspNetCore.Http.ForbidHttpResult.AuthenticationSchemes.get -> System.Collections.Generic.IReadOnlyList!
Microsoft.AspNetCore.Http.ForbidHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
+Microsoft.AspNetCore.Http.ForbidHttpResult.ForbidHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties = null) -> void
+Microsoft.AspNetCore.Http.ForbidHttpResult.ForbidHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties, System.Collections.Generic.IList! authenticationSchemes) -> void
+Microsoft.AspNetCore.Http.ForbidHttpResult.ForbidHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties, string! authenticationScheme) -> void
Microsoft.AspNetCore.Http.ForbidHttpResult.Properties.get -> Microsoft.AspNetCore.Authentication.AuthenticationProperties?
Microsoft.AspNetCore.Http.JsonHttpResult
Microsoft.AspNetCore.Http.JsonHttpResult.ContentType.get -> string?
+Microsoft.AspNetCore.Http.JsonHttpResult.ContentType.init -> void
Microsoft.AspNetCore.Http.JsonHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
+Microsoft.AspNetCore.Http.JsonHttpResult.JsonHttpResult(object? value = null, System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) -> void
Microsoft.AspNetCore.Http.JsonHttpResult.JsonSerializerOptions.get -> System.Text.Json.JsonSerializerOptions?
Microsoft.AspNetCore.Http.JsonHttpResult.StatusCode.get -> int?
+Microsoft.AspNetCore.Http.JsonHttpResult.StatusCode.init -> void
Microsoft.AspNetCore.Http.JsonHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.NoContentHttpResult
Microsoft.AspNetCore.Http.NoContentHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
+Microsoft.AspNetCore.Http.NoContentHttpResult.NoContentHttpResult() -> void
Microsoft.AspNetCore.Http.NoContentHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.NotFoundObjectHttpResult
Microsoft.AspNetCore.Http.NotFoundObjectHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
+Microsoft.AspNetCore.Http.NotFoundObjectHttpResult.NotFoundObjectHttpResult(object? value = null) -> void
Microsoft.AspNetCore.Http.NotFoundObjectHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.NotFoundObjectHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.OkObjectHttpResult
Microsoft.AspNetCore.Http.OkObjectHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
+Microsoft.AspNetCore.Http.OkObjectHttpResult.OkObjectHttpResult(object? value = null) -> void
Microsoft.AspNetCore.Http.OkObjectHttpResult.StatusCode.get -> int
Microsoft.AspNetCore.Http.OkObjectHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.PhysicalFileHttpResult
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.ContentType.get -> string!
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.EnableRangeProcessing.get -> bool
+Microsoft.AspNetCore.Http.PhysicalFileHttpResult.EnableRangeProcessing.init -> void
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.EntityTag.get -> Microsoft.Net.Http.Headers.EntityTagHeaderValue?
+Microsoft.AspNetCore.Http.PhysicalFileHttpResult.EntityTag.init -> void
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.FileDownloadName.get -> string?
+Microsoft.AspNetCore.Http.PhysicalFileHttpResult.FileDownloadName.init -> void
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.FileLength.get -> long?
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.FileName.get -> string!
Microsoft.AspNetCore.Http.PhysicalFileHttpResult.LastModified.get -> System.DateTimeOffset?
+Microsoft.AspNetCore.Http.PhysicalFileHttpResult.LastModified.init -> void
+Microsoft.AspNetCore.Http.PhysicalFileHttpResult.PhysicalFileHttpResult(string! fileName, string? contentType = null) -> void
Microsoft.AspNetCore.Http.ProblemHttpResult
Microsoft.AspNetCore.Http.ProblemHttpResult.ContentType.get -> string!
Microsoft.AspNetCore.Http.ProblemHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.ProblemHttpResult.ProblemDetails.get -> Microsoft.AspNetCore.Mvc.ProblemDetails!
+Microsoft.AspNetCore.Http.ProblemHttpResult.ProblemHttpResult(Microsoft.AspNetCore.Mvc.ProblemDetails! problemDetails) -> void
+Microsoft.AspNetCore.Http.ProblemHttpResult.ProblemHttpResult(string? detail = null, string? instance = null, int? statusCode = null, string? title = null, string? type = null, System.Collections.Generic.IDictionary? extensions = null) -> void
Microsoft.AspNetCore.Http.ProblemHttpResult.StatusCode.get -> int?
Microsoft.AspNetCore.Http.PushStreamHttpResult
Microsoft.AspNetCore.Http.PushStreamHttpResult.ContentType.get -> string!
Microsoft.AspNetCore.Http.PushStreamHttpResult.EnableRangeProcessing.get -> bool
+Microsoft.AspNetCore.Http.PushStreamHttpResult.EnableRangeProcessing.init -> void
Microsoft.AspNetCore.Http.PushStreamHttpResult.EntityTag.get -> Microsoft.Net.Http.Headers.EntityTagHeaderValue?
+Microsoft.AspNetCore.Http.PushStreamHttpResult.EntityTag.init -> void
Microsoft.AspNetCore.Http.PushStreamHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.PushStreamHttpResult.FileDownloadName.get -> string?
+Microsoft.AspNetCore.Http.PushStreamHttpResult.FileDownloadName.init -> void
Microsoft.AspNetCore.Http.PushStreamHttpResult.FileLength.get -> long?
+Microsoft.AspNetCore.Http.PushStreamHttpResult.FileLength.init -> void
Microsoft.AspNetCore.Http.PushStreamHttpResult.LastModified.get -> System.DateTimeOffset?
+Microsoft.AspNetCore.Http.PushStreamHttpResult.LastModified.init -> void
+Microsoft.AspNetCore.Http.PushStreamHttpResult.PushStreamHttpResult(System.Func! streamWriterCallback, string? contentType = null) -> void
Microsoft.AspNetCore.Http.RedirectHttpResult
Microsoft.AspNetCore.Http.RedirectHttpResult.AcceptLocalUrlOnly.get -> bool
Microsoft.AspNetCore.Http.RedirectHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.RedirectHttpResult.Permanent.get -> bool
+Microsoft.AspNetCore.Http.RedirectHttpResult.Permanent.init -> void
Microsoft.AspNetCore.Http.RedirectHttpResult.PreserveMethod.get -> bool
+Microsoft.AspNetCore.Http.RedirectHttpResult.PreserveMethod.init -> void
+Microsoft.AspNetCore.Http.RedirectHttpResult.RedirectHttpResult(string! url, bool acceptLocalUrlOnly = false) -> void
Microsoft.AspNetCore.Http.RedirectHttpResult.Url.get -> string!
Microsoft.AspNetCore.Http.RedirectToRouteHttpResult
Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.Fragment.get -> string?
+Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.Fragment.init -> void
Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.Permanent.get -> bool
+Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.Permanent.init -> void
Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.PreserveMethod.get -> bool
+Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.PreserveMethod.init -> void
+Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.RedirectToRouteHttpResult(string? routeName = null, object? routeValues = null) -> void
Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.RouteName.get -> string?
Microsoft.AspNetCore.Http.RedirectToRouteHttpResult.RouteValues.get -> Microsoft.AspNetCore.Routing.RouteValueDictionary?
Microsoft.AspNetCore.Http.SignInHttpResult
Microsoft.AspNetCore.Http.SignInHttpResult.AuthenticationScheme.get -> string?
+Microsoft.AspNetCore.Http.SignInHttpResult.AuthenticationScheme.init -> void
Microsoft.AspNetCore.Http.SignInHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.SignInHttpResult.Principal.get -> System.Security.Claims.ClaimsPrincipal!
Microsoft.AspNetCore.Http.SignInHttpResult.Properties.get -> Microsoft.AspNetCore.Authentication.AuthenticationProperties?
+Microsoft.AspNetCore.Http.SignInHttpResult.Properties.init -> void
+Microsoft.AspNetCore.Http.SignInHttpResult.SignInHttpResult(System.Security.Claims.ClaimsPrincipal! principal) -> void
Microsoft.AspNetCore.Http.SignOutHttpResult
Microsoft.AspNetCore.Http.SignOutHttpResult.AuthenticationSchemes.get -> System.Collections.Generic.IReadOnlyList!
Microsoft.AspNetCore.Http.SignOutHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.SignOutHttpResult.Properties.get -> Microsoft.AspNetCore.Authentication.AuthenticationProperties?
+Microsoft.AspNetCore.Http.SignOutHttpResult.SignOutHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties = null) -> void
+Microsoft.AspNetCore.Http.SignOutHttpResult.SignOutHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties, System.Collections.Generic.IList! authenticationSchemes) -> void
+Microsoft.AspNetCore.Http.SignOutHttpResult.SignOutHttpResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties? properties, string! authenticationScheme) -> void
Microsoft.AspNetCore.Http.StatusCodeHttpResult
Microsoft.AspNetCore.Http.StatusCodeHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.StatusCodeHttpResult.StatusCode.get -> int
+Microsoft.AspNetCore.Http.StatusCodeHttpResult.StatusCodeHttpResult(int statusCode) -> void
Microsoft.AspNetCore.Http.UnauthorizedHttpResult
Microsoft.AspNetCore.Http.UnauthorizedHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.UnauthorizedHttpResult.StatusCode.get -> int
+Microsoft.AspNetCore.Http.UnauthorizedHttpResult.UnauthorizedHttpResult() -> void
Microsoft.AspNetCore.Http.UnprocessableEntityObjectHttpResult
Microsoft.AspNetCore.Http.UnprocessableEntityObjectHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.UnprocessableEntityObjectHttpResult.StatusCode.get -> int
+Microsoft.AspNetCore.Http.UnprocessableEntityObjectHttpResult.UnprocessableEntityObjectHttpResult(object? error = null) -> void
Microsoft.AspNetCore.Http.UnprocessableEntityObjectHttpResult.Value.get -> object?
Microsoft.AspNetCore.Http.VirtualFileHttpResult
Microsoft.AspNetCore.Http.VirtualFileHttpResult.ContentType.get -> string!
Microsoft.AspNetCore.Http.VirtualFileHttpResult.EnableRangeProcessing.get -> bool
+Microsoft.AspNetCore.Http.VirtualFileHttpResult.EnableRangeProcessing.init -> void
Microsoft.AspNetCore.Http.VirtualFileHttpResult.EntityTag.get -> Microsoft.Net.Http.Headers.EntityTagHeaderValue?
+Microsoft.AspNetCore.Http.VirtualFileHttpResult.EntityTag.init -> void
Microsoft.AspNetCore.Http.VirtualFileHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.VirtualFileHttpResult.FileDownloadName.get -> string?
+Microsoft.AspNetCore.Http.VirtualFileHttpResult.FileDownloadName.init -> void
Microsoft.AspNetCore.Http.VirtualFileHttpResult.FileLength.get -> long?
Microsoft.AspNetCore.Http.VirtualFileHttpResult.FileName.get -> string!
Microsoft.AspNetCore.Http.VirtualFileHttpResult.LastModified.get -> System.DateTimeOffset?
-static Microsoft.AspNetCore.Http.EmptyHttpResult.Instance.get -> Microsoft.AspNetCore.Http.EmptyHttpResult!
+Microsoft.AspNetCore.Http.VirtualFileHttpResult.LastModified.init -> void
+Microsoft.AspNetCore.Http.VirtualFileHttpResult.VirtualFileHttpResult(string! fileName, string? contentType = null) -> void
static Microsoft.AspNetCore.Http.Results.Bytes(System.ReadOnlyMemory contents, string? contentType = null, string? fileDownloadName = null, bool enableRangeProcessing = false, System.DateTimeOffset? lastModified = null, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = null) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Empty.get -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Stream(System.Func! streamWriterCallback, string? contentType = null, string? fileDownloadName = null, System.DateTimeOffset? lastModified = null, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = null) -> Microsoft.AspNetCore.Http.IResult!
diff --git a/src/Http/Http.Results/src/PushStreamHttpResult.cs b/src/Http/Http.Results/src/PushStreamHttpResult.cs
index 71f454af2bf2..7ded72e60b54 100644
--- a/src/Http/Http.Results/src/PushStreamHttpResult.cs
+++ b/src/Http/Http.Results/src/PushStreamHttpResult.cs
@@ -15,87 +15,46 @@ public sealed class PushStreamHttpResult : IResult
{
private readonly Func _streamWriterCallback;
- ///
- /// Creates a new instance with
- /// the provided and the provided .
- ///
- /// The stream writer callback.
- /// The Content-Type header of the response.
- internal PushStreamHttpResult(Func streamWriterCallback, string? contentType)
- : this(streamWriterCallback, contentType, fileDownloadName: null)
- {
- }
-
- ///
- /// Creates a new instance with
- /// the provided , the provided
- /// and the provided .
- ///
- /// The stream writer callback.
- /// The Content-Type header of the response.
- /// The suggested file name.
- internal PushStreamHttpResult(
- Func streamWriterCallback,
- string? contentType,
- string? fileDownloadName)
- : this(streamWriterCallback, contentType, fileDownloadName, enableRangeProcessing: false)
- {
- }
-
///
/// Creates a new instance with the provided values.
///
/// The stream writer callback.
/// The Content-Type header of the response.
- /// The suggested file name.
- /// Set to true to enable range requests processing.
- /// The of when the file was last modified.
- /// The associated with the file.
- internal PushStreamHttpResult(
- Func streamWriterCallback,
- string? contentType,
- string? fileDownloadName,
- bool enableRangeProcessing,
- DateTimeOffset? lastModified = null,
- EntityTagHeaderValue? entityTag = null)
+ public PushStreamHttpResult(Func streamWriterCallback, string? contentType = null)
{
_streamWriterCallback = streamWriterCallback;
ContentType = contentType ?? "application/octet-stream";
- FileDownloadName = fileDownloadName;
- EnableRangeProcessing = enableRangeProcessing;
- LastModified = lastModified;
- EntityTag = entityTag;
}
///
- /// Gets the Content-Type header for the response.
+ /// Gets or sets the file length information .
///
- public string ContentType { get; internal set; }
+ public long? FileLength { get; init; }
///
- /// Gets the file name that will be used in the Content-Disposition header of the response.
+ /// Gets the Content-Type header for the response.
///
- public string? FileDownloadName { get; internal set; }
+ public string ContentType { get; }
///
- /// Gets the last modified information associated with the file result.
+ /// Gets the value that enables range processing for the file result.
///
- public DateTimeOffset? LastModified { get; internal set; }
+ public bool EnableRangeProcessing { get; init; }
///
/// Gets the etag associated with the file result.
///
- public EntityTagHeaderValue? EntityTag { get; internal init; }
+ public EntityTagHeaderValue? EntityTag { get; init; }
///
- /// Gets the value that enables range processing for the file result.
+ /// Gets the file name that will be used in the Content-Disposition header of the response.
///
- public bool EnableRangeProcessing { get; internal init; }
+ public string? FileDownloadName { get; init; }
///
- /// Gets or sets the file length information .
+ /// Gets the last modified information associated with the file result.
///
- public long? FileLength { get; internal set; }
+ public DateTimeOffset? LastModified { get; init; }
///
public Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/RedirectHttpResult.cs b/src/Http/Http.Results/src/RedirectHttpResult.cs
index 3c1bdc6ce911..4273ea03b113 100644
--- a/src/Http/Http.Results/src/RedirectHttpResult.cs
+++ b/src/Http/Http.Results/src/RedirectHttpResult.cs
@@ -18,45 +18,9 @@ public sealed partial class RedirectHttpResult : IResult
/// provided.
///
/// The URL to redirect to.
- internal RedirectHttpResult(string url)
- : this(url, permanent: false)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the values
- /// provided.
- ///
- /// The URL to redirect to.
- /// Specifies whether the redirect should be permanent (301) or temporary (302).
- internal RedirectHttpResult(string url, bool permanent)
- : this(url, permanent, preserveMethod: false)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the values
- /// provided.
- ///
- /// The URL to redirect to.
- /// Specifies whether the redirect should be permanent (301) or temporary (302).
- /// If set to true, make the temporary redirect (307)
- /// or permanent redirect (308) preserve the initial request method.
- internal RedirectHttpResult(string url, bool permanent, bool preserveMethod)
- : this(url, acceptLocalUrlOnly: false, permanent, preserveMethod)
- { }
-
- ///
- /// Initializes a new instance of the class with the values
- /// provided.
- ///
- /// The URL to redirect to.
- /// Specifies whether the redirect should be permanent (301) or temporary (302).
- /// If set to true, make the temporary redirect (307)
- /// or permanent redirect (308) preserve the initial request method.
/// If set to true, only local URLs are accepted
/// and will throw an exception when the supplied URL is not considered local.
- internal RedirectHttpResult(string url, bool acceptLocalUrlOnly, bool permanent, bool preserveMethod)
+ public RedirectHttpResult(string url, bool acceptLocalUrlOnly = false)
{
if (url == null)
{
@@ -69,30 +33,28 @@ internal RedirectHttpResult(string url, bool acceptLocalUrlOnly, bool permanent,
}
Url = url;
- Permanent = permanent;
- PreserveMethod = preserveMethod;
AcceptLocalUrlOnly = acceptLocalUrlOnly;
}
///
- /// Gets the value that specifies that the redirect should be permanent if true or temporary if false.
+ /// Gets the URL to redirect to.
///
- public bool Permanent { get; }
+ public string Url { get; }
///
- /// Gets an indication that the redirect preserves the initial request method.
+ /// Gets an indication that only local URLs are accepted.
///
- public bool PreserveMethod { get; }
+ public bool AcceptLocalUrlOnly { get; }
///
- /// Gets the URL to redirect to.
+ /// Gets the value that specifies that the redirect should be permanent if true or temporary if false.
///
- public string Url { get; }
+ public bool Permanent { get; init; }
///
- /// Gets an indication that only local URLs are accepted.
+ /// Gets an indication that the redirect preserves the initial request method.
///
- public bool AcceptLocalUrlOnly { get; }
+ public bool PreserveMethod { get; init; }
///
public Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs b/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs
index 586694792e59..694701c8c4db 100644
--- a/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs
+++ b/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs
@@ -14,120 +14,16 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed partial class RedirectToRouteHttpResult : IResult
{
- ///
- /// Initializes a new instance of the with the values
- /// provided.
- ///
- /// The parameters for the route.
- internal RedirectToRouteHttpResult(object? routeValues)
- : this(routeName: null, routeValues: routeValues)
- {
- }
-
- ///
- /// Initializes a new instance of the with the values
- /// provided.
- ///
- /// The name of the route.
- /// The parameters for the route.
- internal RedirectToRouteHttpResult(
- string? routeName,
- object? routeValues)
- : this(routeName, routeValues, permanent: false)
- {
- }
-
- ///
- /// Initializes a new instance of the with the values
- /// provided.
- ///
- /// The name of the route.
- /// The parameters for the route.
- /// If set to true, makes the redirect permanent (301).
- /// Otherwise a temporary redirect is used (302).
- internal RedirectToRouteHttpResult(
- string? routeName,
- object? routeValues,
- bool permanent)
- : this(routeName, routeValues, permanent, fragment: null)
- {
- }
-
- ///
- /// Initializes a new instance of the with the values
- /// provided.
- ///
- /// The name of the route.
- /// The parameters for the route.
- /// If set to true, makes the redirect permanent (301).
- /// Otherwise a temporary redirect is used (302).
- /// If set to true, make the temporary redirect (307)
- /// or permanent redirect (308) preserve the initial request method.
- internal RedirectToRouteHttpResult(
- string? routeName,
- object? routeValues,
- bool permanent,
- bool preserveMethod)
- : this(routeName, routeValues, permanent, preserveMethod, fragment: null)
- {
- }
-
- ///
- /// Initializes a new instance of the with the values
- /// provided.
- ///
- /// The name of the route.
- /// The parameters for the route.
- /// The fragment to add to the URL.
- internal RedirectToRouteHttpResult(
- string? routeName,
- object? routeValues,
- string? fragment)
- : this(routeName, routeValues, permanent: false, fragment: fragment)
- {
- }
-
- ///
- /// Initializes a new instance of the with the values
- /// provided.
- ///
- /// The name of the route.
- /// The parameters for the route.
- /// If set to true, makes the redirect permanent (301).
- /// Otherwise a temporary redirect is used (302).
- /// The fragment to add to the URL.
- internal RedirectToRouteHttpResult(
- string? routeName,
- object? routeValues,
- bool permanent,
- string? fragment)
- : this(routeName, routeValues, permanent, preserveMethod: false, fragment: fragment)
- {
- }
-
///
/// Initializes a new instance of the with the values
/// provided.
///
/// The name of the route.
/// The parameters for the route.
- /// If set to true, makes the redirect permanent (301).
- /// Otherwise a temporary redirect is used (302).
- /// If set to true, make the temporary redirect (307)
- /// or permanent redirect (308) preserve the initial request method.
- /// The fragment to add to the URL.
- internal RedirectToRouteHttpResult(
- string? routeName,
- object? routeValues,
- bool permanent,
- bool preserveMethod,
- string? fragment)
+ public RedirectToRouteHttpResult(string? routeName = null, object? routeValues = null)
{
RouteName = routeName;
RouteValues = routeValues == null ? null : new RouteValueDictionary(routeValues);
- PreserveMethod = preserveMethod;
- Permanent = permanent;
- Fragment = fragment;
}
///
@@ -143,17 +39,17 @@ internal RedirectToRouteHttpResult(
///
/// Gets the value that specifies that the redirect should be permanent if true or temporary if false.
///
- public bool Permanent { get; }
+ public bool Permanent { get; init; }
///
/// Gets an indication that the redirect preserves the initial request method.
///
- public bool PreserveMethod { get; }
+ public bool PreserveMethod { get; init; }
///
/// Gets the fragment to add to the URL.
///
- public string? Fragment { get; }
+ public string? Fragment { get; init; }
///
public Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/Results.cs b/src/Http/Http.Results/src/Results.cs
index 89b9c12bde7d..cc1053f7824c 100644
--- a/src/Http/Http.Results/src/Results.cs
+++ b/src/Http/Http.Results/src/Results.cs
@@ -32,7 +32,9 @@ public static class Results
public static IResult Challenge(
AuthenticationProperties? properties = null,
IList? authenticationSchemes = null)
- => new ChallengeHttpResult(authenticationSchemes: authenticationSchemes ?? Array.Empty(), properties);
+ {
+ return new ChallengeHttpResult(properties, authenticationSchemes ?? Array.Empty());
+ }
///
/// Creates a that on execution invokes .
@@ -50,7 +52,9 @@ public static IResult Challenge(
/// a redirect to show a login page.
///
public static IResult Forbid(AuthenticationProperties? properties = null, IList? authenticationSchemes = null)
- => new ForbidHttpResult(authenticationSchemes: authenticationSchemes ?? Array.Empty(), properties);
+ {
+ return new ForbidHttpResult(properties, authenticationSchemes: authenticationSchemes ?? Array.Empty());
+ }
///
/// Creates an that on execution invokes .
@@ -63,7 +67,13 @@ public static IResult SignIn(
ClaimsPrincipal principal,
AuthenticationProperties? properties = null,
string? authenticationScheme = null)
- => new SignInHttpResult(principal, authenticationScheme, properties);
+ {
+ return new SignInHttpResult(principal)
+ {
+ Properties = properties,
+ AuthenticationScheme = authenticationScheme,
+ };
+ }
///
/// Creates an that on execution invokes .
@@ -72,7 +82,7 @@ public static IResult SignIn(
/// The authentication scheme to use for the sign-out operation.
/// The created for the response.
public static IResult SignOut(AuthenticationProperties? properties = null, IList? authenticationSchemes = null)
- => new SignOutHttpResult(authenticationSchemes ?? Array.Empty(), properties);
+ => new SignOutHttpResult(properties, authenticationSchemes ?? Array.Empty());
///
/// Writes the string to the HTTP response.
@@ -107,14 +117,15 @@ public static IResult Content(string content, string? contentType = null, Encodi
///
public static IResult Text(string content, string? contentType = null, Encoding? contentEncoding = null)
{
- MediaTypeHeaderValue? mediaTypeHeaderValue = null;
if (contentType is not null)
{
- mediaTypeHeaderValue = MediaTypeHeaderValue.Parse(contentType);
+ var mediaTypeHeaderValue = MediaTypeHeaderValue.Parse(contentType);
mediaTypeHeaderValue.Encoding = contentEncoding ?? mediaTypeHeaderValue.Encoding;
+
+ return new ContentHttpResult(content, mediaTypeHeaderValue.ToString());
}
- return new ContentHttpResult(content, mediaTypeHeaderValue?.ToString());
+ return new ContentHttpResult(content);
}
///
@@ -138,8 +149,9 @@ public static IResult Content(string content, MediaTypeHeaderValue contentType)
/// Callers should cache an instance of serializer settings to avoid
/// recreating cached data with each call.
public static IResult Json(object? data, JsonSerializerOptions? options = null, string? contentType = null, int? statusCode = null)
- => new JsonHttpResult(data, statusCode, options)
+ => new JsonHttpResult(data, options)
{
+ StatusCode = statusCode,
ContentType = contentType,
};
@@ -153,28 +165,30 @@ public static IResult Json(object? data, JsonSerializerOptions? options = null,
/// This API is an alias for .
///
/// The file contents.
- /// The Content-Type of the file.
- /// The suggested file name.
- /// Set to true to enable range requests processing.
- /// The of when the file was last modified.
- /// The associated with the file.
+ /// The Content-Type of the file.
+ /// The suggested file name.
+ /// Set to true to enable range requests processing.
+ /// The of when the file was last modified.
+ /// The associated with the file.
/// The created for the response.
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public static IResult File(
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
- byte[] fileContents,
+ byte[] fileContents,
string? contentType = null,
string? fileDownloadName = null,
bool enableRangeProcessing = false,
DateTimeOffset? lastModified = null,
EntityTagHeaderValue? entityTag = null)
- => new FileContentHttpResult(fileContents, contentType)
+ {
+ return new FileContentHttpResult(fileContents, contentType)
{
FileDownloadName = fileDownloadName,
EnableRangeProcessing = enableRangeProcessing,
LastModified = lastModified,
EntityTag = entityTag,
};
+ }
///
/// Writes the byte-array content to the response.
@@ -199,13 +213,15 @@ public static IResult Bytes(
bool enableRangeProcessing = false,
DateTimeOffset? lastModified = null,
EntityTagHeaderValue? entityTag = null)
- => new FileContentHttpResult(contents, contentType)
+ {
+ return new FileContentHttpResult(contents, contentType)
{
FileDownloadName = fileDownloadName,
EnableRangeProcessing = enableRangeProcessing,
LastModified = lastModified,
EntityTag = entityTag,
};
+ }
///
/// Writes the byte-array content to the response.
@@ -230,13 +246,15 @@ public static IResult Bytes(
bool enableRangeProcessing = false,
DateTimeOffset? lastModified = null,
EntityTagHeaderValue? entityTag = null)
- => new FileContentHttpResult(contents, contentType)
+ {
+ return new FileContentHttpResult(contents, contentType)
{
FileDownloadName = fileDownloadName,
EnableRangeProcessing = enableRangeProcessing,
LastModified = lastModified,
EntityTag = entityTag,
};
+ }
///
/// Writes the specified to the response.
@@ -263,7 +281,7 @@ public static IResult Bytes(
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public static IResult File(
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
- Stream fileStream,
+ Stream fileStream,
string? contentType = null,
string? fileDownloadName = null,
DateTimeOffset? lastModified = null,
@@ -405,7 +423,7 @@ public static IResult Stream(
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public static IResult File(
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
- string path,
+ string path,
string? contentType = null,
string? fileDownloadName = null,
DateTimeOffset? lastModified = null,
@@ -448,7 +466,13 @@ public static IResult File(
/// If set to true, make the temporary redirect (307) or permanent redirect (308) preserve the initial request method.
/// The created for the response.
public static IResult Redirect(string url, bool permanent = false, bool preserveMethod = false)
- => new RedirectHttpResult(url, permanent, preserveMethod);
+ {
+ return new RedirectHttpResult(url)
+ {
+ Permanent = permanent,
+ PreserveMethod = preserveMethod,
+ };
+ }
///
/// Redirects to the specified .
@@ -464,7 +488,13 @@ public static IResult Redirect(string url, bool permanent = false, bool preserve
/// If set to true, make the temporary redirect (307) or permanent redirect (308) preserve the initial request method.
/// The created for the response.
public static IResult LocalRedirect(string localUrl, bool permanent = false, bool preserveMethod = false)
- => new RedirectHttpResult(localUrl, acceptLocalUrlOnly: true, permanent, preserveMethod);
+ {
+ return new RedirectHttpResult(localUrl, acceptLocalUrlOnly: true)
+ {
+ Permanent = permanent,
+ PreserveMethod = preserveMethod,
+ };
+ }
///
/// Redirects to the specified route.
@@ -482,12 +512,14 @@ public static IResult LocalRedirect(string localUrl, bool permanent = false, boo
/// The fragment to add to the URL.
/// The created for the response.
public static IResult RedirectToRoute(string? routeName = null, object? routeValues = null, bool permanent = false, bool preserveMethod = false, string? fragment = null)
- => new RedirectToRouteHttpResult(
- routeName: routeName,
- routeValues: routeValues,
- permanent: permanent,
- preserveMethod: preserveMethod,
- fragment: fragment);
+ {
+ return new RedirectToRouteHttpResult(routeName, routeValues)
+ {
+ Fragment = fragment,
+ Permanent = permanent,
+ PreserveMethod = preserveMethod,
+ };
+ }
///
/// Creates a object by specifying a .
@@ -569,24 +601,7 @@ public static IResult Problem(
string? type = null,
IDictionary? extensions = null)
{
- var problemDetails = new ProblemDetails
- {
- Detail = detail,
- Instance = instance,
- Status = statusCode,
- Title = title,
- Type = type,
- };
-
- if (extensions is not null)
- {
- foreach (var extension in extensions)
- {
- problemDetails.Extensions.Add(extension);
- }
- }
-
- return new ProblemHttpResult(problemDetails);
+ return new ProblemHttpResult(detail, instance, statusCode, title, type, extensions);
}
///
@@ -705,7 +720,7 @@ public static IResult AcceptedAtRoute(string? routeName = null, object? routeVal
///
/// Produces an empty result response, that when executed will do nothing.
///
- public static IResult Empty { get; } = EmptyHttpResult.Instance;
+ public static IResult Empty { get; } = new EmptyHttpResult();
///
/// Provides a container for external libraries to extend
diff --git a/src/Http/Http.Results/src/SignInHttpResult.cs b/src/Http/Http.Results/src/SignInHttpResult.cs
index a1b0d805e867..b8224cb1d079 100644
--- a/src/Http/Http.Results/src/SignInHttpResult.cs
+++ b/src/Http/Http.Results/src/SignInHttpResult.cs
@@ -15,42 +15,28 @@ public sealed partial class SignInHttpResult : IResult
{
///
/// Initializes a new instance of with the
- /// default authentication scheme.
+ /// specified principal.
///
/// The claims principal containing the user claims.
- internal SignInHttpResult(ClaimsPrincipal principal)
- : this(principal, authenticationScheme: null, properties: null)
- {
- }
-
- ///
- /// Initializes a new instance of with the
- /// specified authentication scheme and .
- ///
- /// The claims principal containing the user claims.
- /// The authentication schemes to use when signing in the user.
- /// used to perform the sign-in operation.
- internal SignInHttpResult(ClaimsPrincipal principal, string? authenticationScheme, AuthenticationProperties? properties)
+ public SignInHttpResult(ClaimsPrincipal principal)
{
Principal = principal ?? throw new ArgumentNullException(nameof(principal));
- AuthenticationScheme = authenticationScheme;
- Properties = properties;
}
///
- /// Gets or sets the authentication scheme that is used to perform the sign-in operation.
+ /// Gets or sets the containing the user claims.
///
- public string? AuthenticationScheme { get; internal init; }
+ public ClaimsPrincipal Principal { get; }
///
- /// Gets or sets the containing the user claims.
+ /// Gets or sets the authentication scheme that is used to perform the sign-in operation.
///
- public ClaimsPrincipal Principal { get; internal init; }
+ public string? AuthenticationScheme { get; init; }
///
/// Gets or sets the used to perform the sign-in operation.
///
- public AuthenticationProperties? Properties { get; internal init; }
+ public AuthenticationProperties? Properties { get; init; }
///
public Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/SignOutHttpResult.cs b/src/Http/Http.Results/src/SignOutHttpResult.cs
index 7d187fe52c15..fd96db89f790 100644
--- a/src/Http/Http.Results/src/SignOutHttpResult.cs
+++ b/src/Http/Http.Results/src/SignOutHttpResult.cs
@@ -13,41 +13,16 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed partial class SignOutHttpResult : IResult
{
- ///
- /// Initializes a new instance of with the default sign out scheme.
- ///
- internal SignOutHttpResult()
- : this(Array.Empty())
- {
- }
-
- ///
- /// Initializes a new instance of with the default sign out scheme.
- /// specified authentication scheme and .
- ///
- /// used to perform the sign-out operation.
- internal SignOutHttpResult(AuthenticationProperties properties)
- : this(Array.Empty(), properties)
- {
- }
-
- ///
- /// Initializes a new instance of with the
- /// specified authentication scheme.
- ///
- /// The authentication scheme to use when signing out the user.
- internal SignOutHttpResult(string authenticationScheme)
- : this(new[] { authenticationScheme })
- {
- }
-
///
/// Initializes a new instance of with the
- /// specified authentication schemes.
+ /// specified .
///
- /// The authentication schemes to use when signing out the user.
- internal SignOutHttpResult(IList authenticationSchemes)
- : this(authenticationSchemes, properties: null)
+ /// used to perform the authentication
+ /// challenge.
+#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
+ public SignOutHttpResult(AuthenticationProperties? properties = null)
+#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
+ : this(properties, authenticationSchemes: Array.Empty())
{
}
@@ -55,10 +30,11 @@ internal SignOutHttpResult(IList authenticationSchemes)
/// Initializes a new instance of with the
/// specified authentication scheme and .
///
- /// The authentication schemes to use when signing out the user.
- /// used to perform the sign-out operation.
- internal SignOutHttpResult(string authenticationScheme, AuthenticationProperties? properties)
- : this(new[] { authenticationScheme }, properties)
+ /// The authentication schemes to challenge.
+ /// used to perform the authentication
+ /// challenge.
+ public SignOutHttpResult(AuthenticationProperties? properties, string authenticationScheme)
+ : this(properties, authenticationSchemes: new[] { authenticationScheme })
{
}
@@ -66,15 +42,11 @@ internal SignOutHttpResult(string authenticationScheme, AuthenticationProperties
/// Initializes a new instance of with the
/// specified authentication schemes and .
///
- /// The authentication scheme to use when signing out the user.
- /// used to perform the sign-out operation.
- internal SignOutHttpResult(IList authenticationSchemes, AuthenticationProperties? properties)
+ /// The authentication scheme to challenge.
+ /// used to perform the authentication
+ /// challenge.
+ public SignOutHttpResult(AuthenticationProperties? properties, IList authenticationSchemes)
{
- if (authenticationSchemes is null)
- {
- throw new ArgumentNullException(nameof(authenticationSchemes));
- }
-
AuthenticationSchemes = authenticationSchemes.AsReadOnly();
Properties = properties;
}
@@ -82,12 +54,12 @@ internal SignOutHttpResult(IList authenticationSchemes, AuthenticationPr
///
/// Gets the authentication schemes that are challenged.
///
- public IReadOnlyList AuthenticationSchemes { get; internal init; }
+ public IReadOnlyList AuthenticationSchemes { get; }
///
/// Gets the used to perform the sign-out operation.
///
- public AuthenticationProperties? Properties { get; internal init; }
+ public AuthenticationProperties? Properties { get; }
///
public async Task ExecuteAsync(HttpContext httpContext)
diff --git a/src/Http/Http.Results/src/StatusCodeHttpResult.cs b/src/Http/Http.Results/src/StatusCodeHttpResult.cs
index 3e24b45a7767..a6422912b6ef 100644
--- a/src/Http/Http.Results/src/StatusCodeHttpResult.cs
+++ b/src/Http/Http.Results/src/StatusCodeHttpResult.cs
@@ -17,7 +17,7 @@ public sealed partial class StatusCodeHttpResult : IResult
/// with the given .
///
/// The HTTP status code of the response.
- internal StatusCodeHttpResult(int statusCode)
+ public StatusCodeHttpResult(int statusCode)
{
StatusCode = statusCode;
}
diff --git a/src/Http/Http.Results/src/UnauthorizedHttpResult.cs b/src/Http/Http.Results/src/UnauthorizedHttpResult.cs
index 79bc2c17dd91..3bc22122393a 100644
--- a/src/Http/Http.Results/src/UnauthorizedHttpResult.cs
+++ b/src/Http/Http.Results/src/UnauthorizedHttpResult.cs
@@ -12,13 +12,6 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed class UnauthorizedHttpResult : IResult
{
- ///
- /// Initializes a new instance of the class.
- ///
- internal UnauthorizedHttpResult()
- {
- }
-
///
/// Gets the HTTP status code.
///
diff --git a/src/Http/Http.Results/src/UnprocessableEntityObjectHttpResult.cs b/src/Http/Http.Results/src/UnprocessableEntityObjectHttpResult.cs
index d1c8eda62dae..774f439cd244 100644
--- a/src/Http/Http.Results/src/UnprocessableEntityObjectHttpResult.cs
+++ b/src/Http/Http.Results/src/UnprocessableEntityObjectHttpResult.cs
@@ -16,10 +16,10 @@ public sealed class UnprocessableEntityObjectHttpResult : IResult
/// Initializes a new instance of the class with the values
/// provided.
///
- /// The value to format in the entity body.
- internal UnprocessableEntityObjectHttpResult(object? value)
+ /// The value to format in the entity body.
+ public UnprocessableEntityObjectHttpResult(object? error = null)
{
- Value = value;
+ Value = error;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
}
diff --git a/src/Http/Http.Results/src/VirtualFileHttpResult.cs b/src/Http/Http.Results/src/VirtualFileHttpResult.cs
index cac64665d23d..5b23d225dcab 100644
--- a/src/Http/Http.Results/src/VirtualFileHttpResult.cs
+++ b/src/Http/Http.Results/src/VirtualFileHttpResult.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
@@ -16,86 +15,56 @@ namespace Microsoft.AspNetCore.Http;
///
public sealed class VirtualFileHttpResult : IResult
{
- private string _fileName;
+ private DateTimeOffset? _lastModified;
///
- /// Creates a new instance with
- /// the provided and the provided .
+ /// Creates a new instance with the provided values.
///
/// The path to the file. The path must be an absolute path.
/// The Content-Type header of the response.
- internal VirtualFileHttpResult(string fileName, string? contentType)
- : this(fileName, contentType, fileDownloadName: null)
+ public VirtualFileHttpResult(string fileName, string? contentType = null)
{
+ FileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
+ ContentType = contentType ?? "application/octet-stream";
}
///
- /// Creates a new instance with
- /// the provided , the provided
- /// and the provided .
+ /// Gets or sets the path to the file that will be sent back as the response.
///
- /// The path to the file. The path must be an absolute path.
- /// The Content-Type header of the response.
- /// The suggested file name.
- internal VirtualFileHttpResult(
- string fileName,
- string? contentType,
- string? fileDownloadName)
- : this(fileName, contentType, fileDownloadName, enableRangeProcessing: false)
- {
- }
+ public string FileName { get; }
///
- /// Creates a new instance with the provided values.
+ /// Gets or sets the file length information .
///
- /// The path to the file. The path must be an absolute path.
- /// The Content-Type header of the response.
- /// The suggested file name.
- /// Set to true to enable range requests processing.
- /// The of when the file was last modified.
- /// The associated with the file.
- internal VirtualFileHttpResult(
- string fileName,
- string? contentType,
- string? fileDownloadName,
- bool enableRangeProcessing,
- DateTimeOffset? lastModified = null,
- EntityTagHeaderValue? entityTag = null)
- {
- FileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
- ContentType = contentType ?? "application/octet-stream";
- FileDownloadName = fileDownloadName;
- EnableRangeProcessing = enableRangeProcessing;
- LastModified = lastModified;
- EntityTag = entityTag;
- }
-
- ///
- public string ContentType { get; internal set; }
-
- ///
- public string? FileDownloadName { get; internal set; }
+ public long? FileLength { get; private set; }
- ///
- public DateTimeOffset? LastModified { get; internal set; }
+ ///
+ /// Gets the Content-Type header for the response.
+ ///
+ public string ContentType { get; }
- ///
- public EntityTagHeaderValue? EntityTag { get; internal init; }
+ ///
+ /// Gets the value that enables range processing for the file result.
+ ///
+ public bool EnableRangeProcessing { get; init; }
- ///
- public bool EnableRangeProcessing { get; internal init; }
+ ///
+ /// Gets the etag associated with the file result.
+ ///
+ public EntityTagHeaderValue? EntityTag { get; init; }
- ///
- public long? FileLength { get; internal set; }
+ ///
+ /// Gets the file name that will be used in the Content-Disposition header of the response.
+ ///
+ public string? FileDownloadName { get; init; }
///
- /// Gets or sets the path to the file that will be sent back as the response.
+ /// Gets the last modified information associated with the file result.
///
- public string FileName
+ public DateTimeOffset? LastModified
{
- get => _fileName;
- [MemberNotNull(nameof(_fileName))]
- internal set => _fileName = value ?? throw new ArgumentNullException(nameof(value));
+ get => _lastModified;
+ init => _lastModified = value;
}
///
@@ -108,7 +77,7 @@ public Task ExecuteAsync(HttpContext httpContext)
{
throw new FileNotFoundException($"Could not find file: {FileName}.", FileName);
}
- LastModified = LastModified ?? fileInfo.LastModified;
+ _lastModified = LastModified ?? fileInfo.LastModified;
FileLength = fileInfo.Length;
// Creating the logger with a string to preserve the category after the refactoring.
diff --git a/src/Http/Http.Results/test/AcceptedAtRouteResultTests.cs b/src/Http/Http.Results/test/AcceptedAtRouteResultTests.cs
index ae0b8f754085..2c7121d3bd8d 100644
--- a/src/Http/Http.Results/test/AcceptedAtRouteResultTests.cs
+++ b/src/Http/Http.Results/test/AcceptedAtRouteResultTests.cs
@@ -20,7 +20,7 @@ public void AcceptedAtRouteResult_ProblemDetails_SetsStatusCodeAndValue()
{ "sample", "route" }
});
var obj = new HttpValidationProblemDetails();
- var result = new AcceptedAtRouteHttpResult(routeValues, obj);
+ var result = new AcceptedAtRouteHttpResult(routeValues: routeValues, value: obj);
// Assert
Assert.Equal(StatusCodes.Status202Accepted, result.StatusCode);
diff --git a/src/Http/Http.Results/test/ChallengeResultTest.cs b/src/Http/Http.Results/test/ChallengeResultTest.cs
index 95817e6ba449..658762ce5738 100644
--- a/src/Http/Http.Results/test/ChallengeResultTest.cs
+++ b/src/Http/Http.Results/test/ChallengeResultTest.cs
@@ -15,7 +15,7 @@ public class ChallengeResultTest
public async Task ChallengeResult_ExecuteAsync()
{
// Arrange
- var result = new ChallengeHttpResult("", null);
+ var result = new ChallengeHttpResult(null, "");
var auth = new Mock();
var httpContext = GetHttpContext(auth);
@@ -30,7 +30,7 @@ public async Task ChallengeResult_ExecuteAsync()
public async Task ChallengeResult_ExecuteAsync_NoSchemes()
{
// Arrange
- var result = new ChallengeHttpResult(new string[] { }, null);
+ var result = new ChallengeHttpResult(null, new string[] { });
var auth = new Mock();
var httpContext = GetHttpContext(auth);
diff --git a/src/Http/Http.Results/test/CreatedAtRouteResultTests.cs b/src/Http/Http.Results/test/CreatedAtRouteResultTests.cs
index 5fd0575a3c35..c270e58683a4 100644
--- a/src/Http/Http.Results/test/CreatedAtRouteResultTests.cs
+++ b/src/Http/Http.Results/test/CreatedAtRouteResultTests.cs
@@ -21,7 +21,7 @@ public void CreatedAtRouteResult_ProblemDetails_SetsStatusCodeAndValue()
{ "sample", "route" }
});
var obj = new HttpValidationProblemDetails();
- var result = new CreatedAtRouteHttpResult(routeValues, obj);
+ var result = new CreatedAtRouteHttpResult( routeValues: routeValues, value: obj);
// Assert
Assert.Equal(StatusCodes.Status201Created, result.StatusCode);
diff --git a/src/Http/Http.Results/test/EmptyResultTest.cs b/src/Http/Http.Results/test/EmptyResultTest.cs
index b8dd30d4dfff..ef3d787ec8b1 100644
--- a/src/Http/Http.Results/test/EmptyResultTest.cs
+++ b/src/Http/Http.Results/test/EmptyResultTest.cs
@@ -11,7 +11,7 @@ public class EmptyResultTest
public async Task EmptyResult_DoesNothing()
{
// Arrange
- var emptyResult = EmptyHttpResult.Instance;
+ var emptyResult = new EmptyHttpResult();
// Act
var httpContext = GetHttpContext();
diff --git a/src/Http/Http.Results/test/ForbidResultTest.cs b/src/Http/Http.Results/test/ForbidResultTest.cs
index d3b770178ded..0a76ede38509 100644
--- a/src/Http/Http.Results/test/ForbidResultTest.cs
+++ b/src/Http/Http.Results/test/ForbidResultTest.cs
@@ -22,7 +22,7 @@ public async Task ExecuteResultAsync_InvokesForbidAsyncOnAuthenticationService()
.Returns(Task.CompletedTask)
.Verifiable();
var httpContext = GetHttpContext(auth.Object);
- var result = new ForbidHttpResult("", null);
+ var result = new ForbidHttpResult(null, "");
// Act
await result.ExecuteAsync(httpContext);
@@ -46,7 +46,7 @@ public async Task ExecuteResultAsync_InvokesForbidAsyncOnAllConfiguredSchemes()
.Returns(Task.CompletedTask)
.Verifiable();
var httpContext = GetHttpContext(auth.Object);
- var result = new ForbidHttpResult(new[] { "Scheme1", "Scheme2" }, authProperties);
+ var result = new ForbidHttpResult(authProperties, new[] { "Scheme1", "Scheme2" });
var routeData = new RouteData();
// Act
@@ -95,10 +95,7 @@ public async Task ExecuteResultAsync_InvokesForbidAsyncWithAuthProperties_WhenAu
.Returns(Task.CompletedTask)
.Verifiable();
var httpContext = GetHttpContext(auth.Object);
- var result = new ForbidHttpResult(expected)
- {
- AuthenticationSchemes = new string[0]
- };
+ var result = new ForbidHttpResult(expected, new string[0]);
var routeData = new RouteData();
// Act
diff --git a/src/Http/Http.Results/test/LocalRedirectResultTest.cs b/src/Http/Http.Results/test/LocalRedirectResultTest.cs
index 33e49752fefd..efaf74b0f0d1 100644
--- a/src/Http/Http.Results/test/LocalRedirectResultTest.cs
+++ b/src/Http/Http.Results/test/LocalRedirectResultTest.cs
@@ -16,11 +16,16 @@ public void Constructor_WithParameterUrl_SetsResultUrlAndNotPermanentOrPreserveM
var url = "/test/url";
// Act
- var result = new RedirectHttpResult(url, acceptLocalUrlOnly: true, false, false);
+ var result = new RedirectHttpResult(url, acceptLocalUrlOnly: true)
+ {
+ Permanent = false,
+ PreserveMethod = false
+ };
// Assert
Assert.False(result.PreserveMethod);
Assert.False(result.Permanent);
+ Assert.True(result.AcceptLocalUrlOnly);
Assert.Same(url, result.Url);
}
@@ -31,11 +36,16 @@ public void Constructor_WithParameterUrlAndPermanent_SetsResultUrlAndPermanentNo
var url = "/test/url";
// Act
- var result = new RedirectHttpResult(url, acceptLocalUrlOnly: true, permanent: true, preserveMethod: false);
+ var result = new RedirectHttpResult(url, acceptLocalUrlOnly: true)
+ {
+ Permanent = true,
+ PreserveMethod = false
+ };
// Assert
Assert.False(result.PreserveMethod);
Assert.True(result.Permanent);
+ Assert.True(result.AcceptLocalUrlOnly);
Assert.Same(url, result.Url);
}
@@ -46,11 +56,16 @@ public void Constructor_WithParameterUrlAndPermanent_SetsResultUrlPermanentAndPr
var url = "/test/url";
// Act
- var result = new RedirectHttpResult(url, acceptLocalUrlOnly: true, permanent: true, preserveMethod: true);
+ var result = new RedirectHttpResult(url, acceptLocalUrlOnly: true)
+ {
+ Permanent = true,
+ PreserveMethod = true
+ };
// Assert
Assert.True(result.PreserveMethod);
Assert.True(result.Permanent);
+ Assert.True(result.AcceptLocalUrlOnly);
Assert.Same(url, result.Url);
}
@@ -63,7 +78,7 @@ public async Task Execute_ReturnsExpectedValues()
var expectedPath = "/Home/About";
var httpContext = GetHttpContext(appRoot);
- var result = new RedirectHttpResult(contentPath, acceptLocalUrlOnly: true, false, false);
+ var result = new RedirectHttpResult(contentPath, acceptLocalUrlOnly: true);
// Act
await result.ExecuteAsync(httpContext);
@@ -86,7 +101,7 @@ public async Task Execute_Throws_ForNonLocalUrl(
{
// Arrange
var httpContext = GetHttpContext(appRoot);
- var result = new RedirectHttpResult(contentPath, acceptLocalUrlOnly: true, false, false);
+ var result = new RedirectHttpResult(contentPath, acceptLocalUrlOnly: true);
// Act & Assert
var exception = await Assert.ThrowsAsync(() => result.ExecuteAsync(httpContext));
@@ -107,7 +122,7 @@ public async Task Execute_Throws_ForNonLocalUrlTilde(
{
// Arrange
var httpContext = GetHttpContext(appRoot);
- var result = new RedirectHttpResult(contentPath, acceptLocalUrlOnly: true, false, false);
+ var result = new RedirectHttpResult(contentPath, acceptLocalUrlOnly: true);
// Act & Assert
var exception = await Assert.ThrowsAsync(() => result.ExecuteAsync(httpContext));
diff --git a/src/Http/Http.Results/test/RedirectResultTest.cs b/src/Http/Http.Results/test/RedirectResultTest.cs
index 207e6c6850b9..e985c776048e 100644
--- a/src/Http/Http.Results/test/RedirectResultTest.cs
+++ b/src/Http/Http.Results/test/RedirectResultTest.cs
@@ -14,7 +14,11 @@ public void RedirectResult_Constructor_WithParameterUrlPermanentAndPreservesMeth
var url = "/test/url";
// Act
- var result = new RedirectHttpResult(url, permanent: true, preserveMethod: true);
+ var result = new RedirectHttpResult(url)
+ {
+ Permanent = true,
+ PreserveMethod = true,
+ };
// Assert
Assert.True(result.PreserveMethod);
@@ -24,7 +28,12 @@ public void RedirectResult_Constructor_WithParameterUrlPermanentAndPreservesMeth
protected override Task ExecuteAsync(HttpContext httpContext, string contentPath)
{
- var redirectResult = new RedirectHttpResult(contentPath, false, false);
+ var redirectResult = new RedirectHttpResult(contentPath)
+ {
+ Permanent = false,
+ PreserveMethod = false,
+ };
+
return redirectResult.ExecuteAsync(httpContext);
}
}
diff --git a/src/Http/Http.Results/test/RedirectToRouteResultTest.cs b/src/Http/Http.Results/test/RedirectToRouteResultTest.cs
index 99dcac7836dc..c18f62924012 100644
--- a/src/Http/Http.Results/test/RedirectToRouteResultTest.cs
+++ b/src/Http/Http.Results/test/RedirectToRouteResultTest.cs
@@ -56,7 +56,11 @@ public async Task ExecuteResultAsync_WithFragment_PassesCorrectValuesToRedirect(
var expectedStatusCode = StatusCodes.Status301MovedPermanently;
var httpContext = GetHttpContext(expectedUrl);
- var result = new RedirectToRouteHttpResult("Sample", null, true, "test");
+ var result = new RedirectToRouteHttpResult("Sample", null)
+ {
+ Permanent = true,
+ Fragment = "test",
+ };
// Act
await result.ExecuteAsync(httpContext);
@@ -74,7 +78,12 @@ public async Task ExecuteResultAsync_WithFragment_PassesCorrectValuesToRedirect_
var expectedStatusCode = StatusCodes.Status308PermanentRedirect;
var httpContext = GetHttpContext(expectedUrl);
- var result = new RedirectToRouteHttpResult("Sample", null, true, true, "test");
+ var result = new RedirectToRouteHttpResult("Sample", null)
+ {
+ Permanent = true,
+ PreserveMethod = true,
+ Fragment = "test",
+ };
// Act
await result.ExecuteAsync(httpContext);
diff --git a/src/Http/Http.Results/test/SignInResultTest.cs b/src/Http/Http.Results/test/SignInResultTest.cs
index 6aef97223c54..4e9358b5c589 100644
--- a/src/Http/Http.Results/test/SignInResultTest.cs
+++ b/src/Http/Http.Results/test/SignInResultTest.cs
@@ -24,7 +24,11 @@ public async Task ExecuteAsync_InvokesSignInAsyncOnAuthenticationManager()
.Verifiable();
var httpContext = GetHttpContext(auth.Object);
- var result = new SignInHttpResult(principal, "", null);
+ var result = new SignInHttpResult(principal)
+ {
+ AuthenticationScheme = "",
+ Properties = null,
+ };
// Act
await result.ExecuteAsync(httpContext);
@@ -65,7 +69,11 @@ public async Task ExecuteAsync_InvokesSignInAsyncOnConfiguredScheme()
.Returns(Task.CompletedTask)
.Verifiable();
var httpContext = GetHttpContext(auth.Object);
- var result = new SignInHttpResult(principal, "Scheme1", authProperties);
+ var result = new SignInHttpResult(principal)
+ {
+ AuthenticationScheme = "Scheme1",
+ Properties = authProperties,
+ };
// Act
await result.ExecuteAsync(httpContext);
diff --git a/src/Http/Http.Results/test/SignOutResultTest.cs b/src/Http/Http.Results/test/SignOutResultTest.cs
index d3cfa5073659..6f4b6a20d91a 100644
--- a/src/Http/Http.Results/test/SignOutResultTest.cs
+++ b/src/Http/Http.Results/test/SignOutResultTest.cs
@@ -40,7 +40,7 @@ public async Task ExecuteAsync_InvokesSignOutAsyncOnAuthenticationManager()
.Returns(Task.CompletedTask)
.Verifiable();
var httpContext = GetHttpContext(auth.Object);
- var result = new SignOutHttpResult("", null);
+ var result = new SignOutHttpResult(null, "");
// Act
await result.ExecuteAsync(httpContext);
@@ -64,7 +64,7 @@ public async Task ExecuteAsync_InvokesSignOutAsyncOnAllConfiguredSchemes()
.Returns(Task.CompletedTask)
.Verifiable();
var httpContext = GetHttpContext(auth.Object);
- var result = new SignOutHttpResult(new[] { "Scheme1", "Scheme2" }, authProperties);
+ var result = new SignOutHttpResult(authProperties, new[] { "Scheme1", "Scheme2" });
// Act
await result.ExecuteAsync(httpContext);