diff --git a/src/Http/Http.Results/src/AcceptedAtRoute.cs b/src/Http/Http.Results/src/AcceptedAtRoute.cs
index cdc91cfcd4dd..8ab753f83acc 100644
--- a/src/Http/Http.Results/src/AcceptedAtRoute.cs
+++ b/src/Http/Http.Results/src/AcceptedAtRoute.cs
@@ -50,10 +50,10 @@ internal AcceptedAtRoute(string? routeName, object? routeValues)
/// The route data to use for generating the URL.
internal AcceptedAtRoute(
string? routeName,
- RouteValueDictionary routeValues)
+ RouteValueDictionary? routeValues)
{
RouteName = routeName;
- RouteValues = routeValues;
+ RouteValues = routeValues ?? new RouteValueDictionary();
}
///
diff --git a/src/Http/Http.Results/src/AcceptedAtRouteOfT.cs b/src/Http/Http.Results/src/AcceptedAtRouteOfT.cs
index dc45eba65954..1d681bdf8438 100644
--- a/src/Http/Http.Results/src/AcceptedAtRouteOfT.cs
+++ b/src/Http/Http.Results/src/AcceptedAtRouteOfT.cs
@@ -54,12 +54,12 @@ internal AcceptedAtRoute(string? routeName, object? routeValues, TValue? value)
/// The value to format in the entity body.
internal AcceptedAtRoute(
string? routeName,
- RouteValueDictionary routeValues,
+ RouteValueDictionary? routeValues,
TValue? value)
{
Value = value;
RouteName = routeName;
- RouteValues = routeValues;
+ RouteValues = routeValues ?? new RouteValueDictionary();
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
}
diff --git a/src/Http/Http.Results/src/CreatedAtRoute.cs b/src/Http/Http.Results/src/CreatedAtRoute.cs
index 9948e811de16..aeb115b5b30b 100644
--- a/src/Http/Http.Results/src/CreatedAtRoute.cs
+++ b/src/Http/Http.Results/src/CreatedAtRoute.cs
@@ -50,10 +50,10 @@ internal CreatedAtRoute(string? routeName, object? routeValues)
/// The route data to use for generating the URL.
internal CreatedAtRoute(
string? routeName,
- RouteValueDictionary routeValues)
+ RouteValueDictionary? routeValues)
{
RouteName = routeName;
- RouteValues = routeValues;
+ RouteValues = routeValues ?? new RouteValueDictionary();
}
///
diff --git a/src/Http/Http.Results/src/CreatedAtRouteOfT.cs b/src/Http/Http.Results/src/CreatedAtRouteOfT.cs
index f5b026979c5f..3f674d615c3f 100644
--- a/src/Http/Http.Results/src/CreatedAtRouteOfT.cs
+++ b/src/Http/Http.Results/src/CreatedAtRouteOfT.cs
@@ -54,12 +54,12 @@ internal CreatedAtRoute(string? routeName, object? routeValues, TValue? value)
/// The value to format in the entity body.
internal CreatedAtRoute(
string? routeName,
- RouteValueDictionary routeValues,
+ RouteValueDictionary? routeValues,
TValue? value)
{
Value = value;
RouteName = routeName;
- RouteValues = routeValues;
+ RouteValues = routeValues ?? new RouteValueDictionary();
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
}
diff --git a/src/Http/Http.Results/src/PublicAPI.Unshipped.txt b/src/Http/Http.Results/src/PublicAPI.Unshipped.txt
index 393991164c2b..c3143932a894 100644
--- a/src/Http/Http.Results/src/PublicAPI.Unshipped.txt
+++ b/src/Http/Http.Results/src/PublicAPI.Unshipped.txt
@@ -4,7 +4,11 @@
*REMOVED*static Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult.Instance.get -> Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult!
Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult (forwarded, contained in Microsoft.AspNetCore.Http.Abstractions)
Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task! (forwarded, contained in Microsoft.AspNetCore.Http.Abstractions)
+Microsoft.AspNetCore.Http.HttpResults.RedirectToRouteHttpResult.RouteValues.get -> Microsoft.AspNetCore.Routing.RouteValueDictionary!
+*REMOVED*Microsoft.AspNetCore.Http.HttpResults.RedirectToRouteHttpResult.RouteValues.get -> Microsoft.AspNetCore.Routing.RouteValueDictionary?
static Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult.Instance.get -> Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult! (forwarded, contained in Microsoft.AspNetCore.Http.Abstractions)
+static Microsoft.AspNetCore.Http.Results.AcceptedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, object? value = null) -> Microsoft.AspNetCore.Http.IResult!
+static Microsoft.AspNetCore.Http.Results.AcceptedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, TValue? value = default(TValue?)) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Created() -> Microsoft.AspNetCore.Http.IResult!
*REMOVED*static Microsoft.AspNetCore.Http.Results.Created(string! uri, object? value) -> Microsoft.AspNetCore.Http.IResult!
*REMOVED*static Microsoft.AspNetCore.Http.Results.Created(System.Uri! uri, object? value) -> Microsoft.AspNetCore.Http.IResult!
@@ -12,10 +16,15 @@ static Microsoft.AspNetCore.Http.Results.Created(string? uri, object? value) ->
static Microsoft.AspNetCore.Http.Results.Created(System.Uri? uri, object? value) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Created(string? uri, TValue? value) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Created(System.Uri? uri, TValue? value) -> Microsoft.AspNetCore.Http.IResult!
+static Microsoft.AspNetCore.Http.Results.CreatedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, object? value = null) -> Microsoft.AspNetCore.Http.IResult!
+static Microsoft.AspNetCore.Http.Results.CreatedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, TValue? value = default(TValue?)) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Json(object? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo! jsonTypeInfo, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Json(object? data, System.Type! type, System.Text.Json.Serialization.JsonSerializerContext! context, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Json(TValue? data, System.Text.Json.Serialization.JsonSerializerContext! context, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
static Microsoft.AspNetCore.Http.Results.Json(TValue? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo! jsonTypeInfo, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
+static Microsoft.AspNetCore.Http.Results.RedirectToRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, bool permanent = false, bool preserveMethod = false, string? fragment = null) -> Microsoft.AspNetCore.Http.IResult!
+static Microsoft.AspNetCore.Http.TypedResults.AcceptedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.AcceptedAtRoute!
+static Microsoft.AspNetCore.Http.TypedResults.AcceptedAtRoute(TValue? value, string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.AcceptedAtRoute!
static Microsoft.AspNetCore.Http.TypedResults.Created() -> Microsoft.AspNetCore.Http.HttpResults.Created!
static Microsoft.AspNetCore.Http.TypedResults.Created(string? uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
static Microsoft.AspNetCore.Http.TypedResults.Created(System.Uri? uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
@@ -27,5 +36,8 @@ static Microsoft.AspNetCore.Http.TypedResults.Created(System.Uri? uri, T
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created(string! uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created(System.Uri! uri, TValue? value) -> Microsoft.AspNetCore.Http.HttpResults.Created!
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created(string! uri, TValue? value) -> Microsoft.AspNetCore.Http.HttpResults.Created!
+static Microsoft.AspNetCore.Http.TypedResults.CreatedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.CreatedAtRoute!
+static Microsoft.AspNetCore.Http.TypedResults.CreatedAtRoute(TValue? value, string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.CreatedAtRoute!
static Microsoft.AspNetCore.Http.TypedResults.Json(TValue? data, System.Text.Json.Serialization.JsonSerializerContext! context, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.HttpResults.JsonHttpResult!
static Microsoft.AspNetCore.Http.TypedResults.Json(TValue? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo! jsonTypeInfo, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.HttpResults.JsonHttpResult!
+static Microsoft.AspNetCore.Http.TypedResults.RedirectToRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, bool permanent = false, bool preserveMethod = false, string? fragment = null) -> Microsoft.AspNetCore.Http.HttpResults.RedirectToRouteHttpResult!
diff --git a/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs b/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs
index bd823fc9c13b..2e491f3151a1 100644
--- a/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs
+++ b/src/Http/Http.Results/src/RedirectToRouteHttpResult.cs
@@ -96,7 +96,7 @@ internal RedirectToRouteHttpResult(
bool preserveMethod,
string? fragment) : this(
routeName,
- routeValues == null ? null : new RouteValueDictionary(routeValues),
+ new RouteValueDictionary(routeValues),
permanent,
preserveMethod,
fragment)
@@ -122,7 +122,7 @@ internal RedirectToRouteHttpResult(
string? fragment)
{
RouteName = routeName;
- RouteValues = routeValues;
+ RouteValues = routeValues ?? new RouteValueDictionary();
PreserveMethod = preserveMethod;
Permanent = permanent;
Fragment = fragment;
@@ -136,7 +136,7 @@ internal RedirectToRouteHttpResult(
///
/// Gets the route data to use for generating the URL.
///
- public RouteValueDictionary? RouteValues { get; }
+ public RouteValueDictionary RouteValues { get; }
///
/// Gets the value that specifies that the redirect should be permanent if true or temporary if false.
diff --git a/src/Http/Http.Results/src/Results.cs b/src/Http/Http.Results/src/Results.cs
index ab760c99f429..20ab2f6a2297 100644
--- a/src/Http/Http.Results/src/Results.cs
+++ b/src/Http/Http.Results/src/Results.cs
@@ -13,6 +13,7 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Routing;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Http;
@@ -146,9 +147,7 @@ public static IResult Text(string? content, string? contentType, Encoding? conte
/// If encoding is provided by both the 'charset' and the parameters, then
/// the parameter is chosen as the final encoding.
///
-#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public static IResult Text(string? content, string? contentType = null, Encoding? contentEncoding = null, int? statusCode = null)
-#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
=> TypedResults.Text(content, contentType, contentEncoding, statusCode);
///
@@ -158,9 +157,7 @@ public static IResult Text(string? content, string? contentType = null, Encoding
/// The content type (MIME type).
/// The status code to return.
/// The created object for the response.
-#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads
public static IResult Text(ReadOnlySpan utf8Content, string? contentType = null, int? statusCode = null)
-#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads
=> TypedResults.Text(utf8Content, contentType, statusCode);
///
@@ -241,7 +238,6 @@ public static IResult Json(object? data, Type type, JsonSerializerContext contex
/// recreating cached data with each call.
[RequiresUnreferencedCode(JsonHttpResultTrimmerWarning.SerializationUnreferencedCodeMessage)]
[RequiresDynamicCode(JsonHttpResultTrimmerWarning.SerializationRequiresDynamicCodeMessage)]
-#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public static IResult Json(TValue? data, JsonSerializerOptions? options = null, string? contentType = null, int? statusCode = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
=> TypedResults.Json(data, options, contentType, statusCode);
@@ -294,9 +290,7 @@ public static IResult Json(TValue? data, JsonSerializerContext context,
/// 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,
string? contentType = null,
string? fileDownloadName = null,
@@ -344,9 +338,7 @@ public static IResult Bytes(
/// 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 Bytes(
-#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
ReadOnlyMemory contents,
string? contentType = null,
string? fileDownloadName = null,
@@ -377,9 +369,7 @@ public static IResult Bytes(
///
/// The parameter is disposed after the response is sent.
///
-#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,
string? contentType = null,
string? fileDownloadName = null,
@@ -438,9 +428,7 @@ public static IResult Stream(
///
/// The parameter is completed after the response is sent.
///
-#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public static IResult Stream(
-#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
PipeReader pipeReader,
string? contentType = null,
string? fileDownloadName = null,
@@ -464,9 +452,7 @@ public static IResult Stream(
/// The to be configure the ETag response header
/// and perform conditional requests.
/// The created for the response.
-#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public static IResult Stream(
-#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
Func streamWriterCallback,
string? contentType = null,
string? fileDownloadName = null,
@@ -488,9 +474,7 @@ public static IResult Stream(
/// The associated with the file.
/// Set to true to enable range requests processing.
/// 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
string path,
string? contentType = null,
string? fileDownloadName = null,
@@ -576,6 +560,34 @@ public static IResult LocalRedirect([StringSyntax(StringSyntaxAttribute.Uri, Uri
public static IResult RedirectToRoute(string? routeName = null, object? routeValues = null, bool permanent = false, bool preserveMethod = false, string? fragment = null)
=> TypedResults.RedirectToRoute(routeName, routeValues, permanent, preserveMethod, fragment);
+ ///
+ /// Redirects to the specified route.
+ ///
+ ///
+ /// When and are set, sets the status code.
+ ///
+ ///
+ /// When is set, sets the status code.
+ ///
+ ///
+ /// When is set, sets the status code.
+ ///
+ ///
+ /// Otherwise, configures .
+ ///
+ ///
+ ///
+ /// The name of the route.
+ /// The parameters for a route.
+ /// 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.
+ /// The fragment to add to the URL.
+ /// The created for the response.
+#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
+ public static IResult RedirectToRoute(string? routeName, RouteValueDictionary? routeValues, bool permanent = false, bool preserveMethod = false, string? fragment = null)
+#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
+ => TypedResults.RedirectToRoute(routeName, routeValues, permanent, preserveMethod, fragment);
+
///
/// Creates an object by specifying a .
///
@@ -589,9 +601,7 @@ public static IResult StatusCode(int statusCode)
///
/// The value to be included in the HTTP response body.
/// The created for the response.
-#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
public static IResult NotFound(object? value = null)
-#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
=> NotFound