diff --git a/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs b/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs index 85e45095e6..9bc0637879 100644 --- a/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs +++ b/src/Microsoft.AspNet.OData.Shared/GetNextPageHelper.cs @@ -6,6 +6,7 @@ using System.Diagnostics.Contracts; using System.Globalization; using System.Text; +using System.Web; namespace Microsoft.AspNet.OData { @@ -14,7 +15,7 @@ namespace Microsoft.AspNet.OData /// internal static partial class GetNextPageHelper { - internal static Uri GetNextPageLink(Uri requestUri, IEnumerable> queryParameters, int pageSize, object instance = null, Func objectToSkipTokenValue = null, CompatibilityOptions options = CompatibilityOptions.None) + internal static Uri GetNextPageLink(Uri requestUri, IEnumerable> queryParameters, int pageSize, object instance = null, Func objectToSkipTokenValue = null, CompatibilityOptions options = CompatibilityOptions.None, bool encodeUrl = false) { Contract.Assert(requestUri != null); Contract.Assert(queryParameters != null); @@ -96,7 +97,7 @@ internal static Uri GetNextPageLink(Uri requestUri, IEnumerableThe page size. /// The instance based on which the skiptoken value is generated /// Function that takes in the last object and returns the skiptoken value string. + /// Optional Parameter to determine whether the nextpace url should be encoded. /// - Uri GetNextPageLink(int pageSize, object instance, Func objToSkipTokenValue); + Uri GetNextPageLink(int pageSize, object instance, Func objToSkipTokenValue,bool encodeUrl); /// /// Get a list of content Id mappings associated with the request. diff --git a/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs b/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs index bccaaf3b62..054b09cecb 100644 --- a/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs +++ b/src/Microsoft.AspNet.OData.Shared/Query/DefaultSkipTokenHandler.cs @@ -72,7 +72,7 @@ public override Uri GenerateNextPageLink(Uri baseUri, int pageSize, Object insta return GenerateSkipTokenValue(obj, model, orderByNodes); }; - return GetNextPageHelper.GetNextPageLink(baseUri, pageSize, instance, skipTokenGenerator); + return GetNextPageHelper.GetNextPageLink(baseUri, pageSize, instance, skipTokenGenerator,encodeUrl:true); } if (context.QueryOptions != null && context.QueryOptions.OrderBy != null) @@ -86,7 +86,7 @@ public override Uri GenerateNextPageLink(Uri baseUri, int pageSize, Object insta }; } - return context.InternalRequest.GetNextPageLink(pageSize, instance, skipTokenGenerator); + return context.InternalRequest.GetNextPageLink(pageSize, instance, skipTokenGenerator, encodeUrl: true); } /// diff --git a/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs b/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs index 2d59682526..6679079777 100644 --- a/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs +++ b/src/Microsoft.AspNetCore.OData/Adapters/WebApiRequestMessage.cs @@ -138,10 +138,11 @@ public ODataDeserializerProvider DeserializerProvider /// The page size. /// Object which will be used to generate the skiptoken value. /// Function that takes in an instance and returns the skiptoken value string. + /// Optional Parameter to determine whether the nextpace url should be encoded. /// - public Uri GetNextPageLink(int pageSize, object instance = null, Func objToSkipTokenValue = null) + public Uri GetNextPageLink(int pageSize, object instance = null, Func objToSkipTokenValue = null,bool encodeUrl =false) { - return this.innerRequest.GetNextPageLink(pageSize, instance, objToSkipTokenValue); + return this.innerRequest.GetNextPageLink(pageSize, instance, objToSkipTokenValue,encodeUrl:encodeUrl); } /// diff --git a/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs b/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs index 84453ef594..b1629df2d1 100644 --- a/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs +++ b/src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs @@ -263,10 +263,11 @@ public static ETag GetETag(this HttpRequest request, EntityTag /// /// The request on which to base the next page link. /// The number of results allowed per page. + /// Optional Parameter to determine whether the nextpace url should be encoded. /// A next page link. - public static Uri GetNextPageLink(this HttpRequest request, int pageSize) + public static Uri GetNextPageLink(this HttpRequest request, int pageSize,bool encodeUrl =false) { - return GetNextPageLink(request, pageSize, null, null); + return GetNextPageLink(request, pageSize, null, null); } /// @@ -276,8 +277,9 @@ public static Uri GetNextPageLink(this HttpRequest request, int pageSize) /// The number of results allowed per page. /// Object which can be used to generate the skiptoken value. /// Function that takes in the last object and returns the skiptoken value string. + /// Optional Parameter to determine whether the nextpace url should be encoded. /// A next page link. - public static Uri GetNextPageLink(this HttpRequest request, int pageSize, object instance, Func objectToSkipTokenValue) + public static Uri GetNextPageLink(this HttpRequest request, int pageSize, object instance, Func objectToSkipTokenValue, bool encodeUrl = false) { if (request == null) { diff --git a/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs b/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs index 4520b25a9d..b1cc88f7ca 100644 --- a/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs +++ b/src/Microsoft.AspNetCore.OData/GetNextPageHelper.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNet.OData internal static partial class GetNextPageHelper { /// This signature uses types that are AspNetCore-specific. - internal static Uri GetNextPageLink(Uri requestUri, int pageSize, object instance = null, Func objectToSkipTokenValue = null) + internal static Uri GetNextPageLink(Uri requestUri, int pageSize, object instance = null, Func objectToSkipTokenValue = null, bool encodeUrl =false) { Contract.Assert(requestUri != null); @@ -24,7 +24,7 @@ internal static Uri GetNextPageLink(Uri requestUri, int pageSize, object instanc IEnumerable> queryParameters = queryValues.SelectMany( kvp => kvp.Value, (kvp, value) => new KeyValuePair(kvp.Key, value)); - return GetNextPageLink(requestUri, queryParameters, pageSize, instance, objectToSkipTokenValue); + return GetNextPageLink(requestUri, queryParameters, pageSize, instance, objectToSkipTokenValue,encodeUrl:encodeUrl); } } }