diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/WebRequestPathBuilder.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/WebRequestPathBuilder.mustache index 30e5181eeace..cc811ae4f983 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/WebRequestPathBuilder.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/WebRequestPathBuilder.mustache @@ -1,6 +1,6 @@ {{>partial_header}} +using System; using System.Collections.Generic; -using System.Web; namespace {{packageName}}.Client { @@ -22,7 +22,7 @@ namespace {{packageName}}.Client { foreach (var parameter in parameters) { - _path = _path.Replace("{" + parameter.Key + "}", HttpUtility.UrlEncode(parameter.Value)); + _path = _path.Replace("{" + parameter.Key + "}", Uri.EscapeDataString(parameter.Value)); } } @@ -32,7 +32,7 @@ namespace {{packageName}}.Client { foreach (var value in parameter.Value) { - _query = _query + parameter.Key + "=" + HttpUtility.UrlEncode(value) + "&"; + _query = _query + parameter.Key + "=" + Uri.EscapeDataString(value) + "&"; } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/WebRequestPathBuilder.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/WebRequestPathBuilder.cs index 62cdf6a1d9be..e4af746d7d6d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/WebRequestPathBuilder.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/WebRequestPathBuilder.cs @@ -7,8 +7,8 @@ * Generated by: https://github.com/openapitools/openapi-generator.git */ +using System; using System.Collections.Generic; -using System.Web; namespace Org.OpenAPITools.Client { @@ -30,7 +30,7 @@ public void AddPathParameters(Dictionary parameters) { foreach (var parameter in parameters) { - _path = _path.Replace("{" + parameter.Key + "}", HttpUtility.UrlEncode(parameter.Value)); + _path = _path.Replace("{" + parameter.Key + "}", Uri.EscapeDataString(parameter.Value)); } } @@ -40,7 +40,7 @@ public void AddQueryParameters(Multimap parameters) { foreach (var value in parameter.Value) { - _query = _query + parameter.Key + "=" + HttpUtility.UrlEncode(value) + "&"; + _query = _query + parameter.Key + "=" + Uri.EscapeDataString(value) + "&"; } } }