diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets
index 75af1e423eef42..aead4c44795909 100644
--- a/src/mono/sample/wasi/Directory.Build.targets
+++ b/src/mono/sample/wasi/Directory.Build.targets
@@ -16,13 +16,13 @@
-->
+ Command="$(WasmtimeDir)wasmtime$(_ExeExt) $(MONO_LOG_LEVEL) -S http --dir . dotnet.wasm $(_SampleProjectName)" IgnoreExitCode="true" />
+ Command="$(WasmtimeDir)wasmtime$(_ExeExt) $(MONO_LOG_LEVEL) -S http --dir . dotnet.wasm" IgnoreExitCode="true" />
+ Command="$(WasmtimeDir)wasmtime$(_ExeExt) $(MONO_LOG_LEVEL) -S http $([System.IO.Path]::ChangeExtension($(_SampleAssembly), '.wasm'))" IgnoreExitCode="true" />
diff --git a/src/mono/sample/wasi/http-p2/Program.cs b/src/mono/sample/wasi/http-p2/Program.cs
new file mode 100644
index 00000000000000..f2687d511fc151
--- /dev/null
+++ b/src/mono/sample/wasi/http-p2/Program.cs
@@ -0,0 +1,57 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Net.Http.Headers;
+using System.Net.Http;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Runtime.CompilerServices;
+
+public class Test
+{
+ public static int Main(string[] args)
+ {
+ var task = Work();
+ while (!task.IsCompleted)
+ {
+ WasiEventLoop.DispatchWasiEventLoop();
+ }
+ var exception = task.Exception;
+ if (exception is not null)
+ {
+ throw exception;
+ }
+
+ return 0;
+ }
+
+ public static async Task Work()
+ {
+ using HttpClient client = new();
+ client.Timeout = Timeout.InfiniteTimeSpan;
+ client.DefaultRequestHeaders.Accept.Clear();
+ client.DefaultRequestHeaders.Accept.Add(
+ new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
+ client.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter");
+
+ var query="https://api.github.com/orgs/dotnet/repos?per_page=1";
+ var json = await client.GetStringAsync(query);
+
+ Console.WriteLine();
+ Console.WriteLine("GET "+query);
+ Console.WriteLine();
+ Console.WriteLine(json);
+ }
+
+ private static class WasiEventLoop
+ {
+ internal static void DispatchWasiEventLoop()
+ {
+ CallDispatchWasiEventLoop((Thread)null!);
+
+ [UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "DispatchWasiEventLoop")]
+ static extern void CallDispatchWasiEventLoop(Thread t);
+ }
+ }
+}
diff --git a/src/mono/sample/wasi/http-p2/Wasip2.Http.Console.Sample.csproj b/src/mono/sample/wasi/http-p2/Wasip2.Http.Console.Sample.csproj
new file mode 100644
index 00000000000000..cb410fa78f843a
--- /dev/null
+++ b/src/mono/sample/wasi/http-p2/Wasip2.Http.Console.Sample.csproj
@@ -0,0 +1,11 @@
+
+
+ $(NetCoreAppCurrent)
+
+
+
+
+