diff --git a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj
index f87bfb74c63e7e..1fb12930ce1854 100644
--- a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj
+++ b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj
@@ -35,5 +35,6 @@
+
diff --git a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs
index 37ea6293e8b50a..b23317fdc22b8e 100644
--- a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs
+++ b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs
@@ -12,6 +12,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using System.Web;
namespace System.Net
{
@@ -1175,7 +1176,7 @@ private string MapToDefaultMethod(Uri address)
[return: NotNullIfNotNull(nameof(str))]
private static string? UrlEncode(string? str) =>
str is null ? null :
- WebUtility.UrlEncode(str);
+ HttpUtility.UrlEncode(str);
private void InvokeOperationCompleted(AsyncOperation asyncOp, SendOrPostCallback callback, AsyncCompletedEventArgs eventArgs)
{
diff --git a/src/libraries/System.Net.WebClient/tests/WebClientTest.cs b/src/libraries/System.Net.WebClient/tests/WebClientTest.cs
index ec363013e846da..cc3079e80bf2f2 100644
--- a/src/libraries/System.Net.WebClient/tests/WebClientTest.cs
+++ b/src/libraries/System.Net.WebClient/tests/WebClientTest.cs
@@ -489,7 +489,7 @@ public abstract class WebClientTestBase
const string ExpectedTextAfterUrlEncode =
"To+be%2c+or+not+to+be%2c+that+is+the+question%3a" +
- "Whether+'tis+Nobler+in+the+mind+to+suffer" +
+ "Whether+%27tis+Nobler+in+the+mind+to+suffer" +
"The+Slings+and+Arrows+of+outrageous+Fortune%2c" +
"Or+to+take+Arms+against+a+Sea+of+troubles%2c" +
"And+by+opposing+end+them%3a";