Skip to content

Commit f8587fd

Browse files
committed
Updated examples to comply to .Net SDK 9.0 and its templates' structures.
1 parent a5b5fbd commit f8587fd

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "DotNet: HTTP request from WASM",
2+
"name": ".Net: HTTP request from WASM",
33
"image": "mcr.microsoft.com/dotnet/sdk:9.0",
44
"features": {
55
"ghcr.io/devcontainers/features/common-utils": {},

browser-and-node-RestSharp/node/README.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,29 @@ cd browser-and-node-RestSharp/node
2020
2. Create new .Net project using `wasmconsole` template:
2121

2222
```sh
23-
dotnet new wasmconsole
23+
dotnet new wasmconsole -n NodeProject
2424
```
2525

2626
3. Replace generated HelloWorld-like `Program.cs` and `main.mjs` with HTTP-enabled ones:
2727

2828
```sh
29-
cp ../Program.cs ./
30-
cp ../main.js ./main.mjs
29+
cp ../Program.cs ./NodeProject/
30+
cp ../main.js ./NodeProject/main.mjs
3131
```
3232

33-
4. Compile the example:
33+
4. `cd` into the folder of the new .Net project to use it:
34+
35+
```sh
36+
cd NodeProject
37+
```
38+
39+
5. Install RestSharp library as dependency:
40+
41+
```sh
42+
dotnet add package RestSharp
43+
```
44+
45+
6. Compile the example:
3446

3547
```sh
3648
dotnet build

browser-and-node/browser/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Instructions for this devcontainer
44

5-
Tested with .Net version 8.0.100-rc.2.23502.2 .
5+
Tested with .Net SDK version 9.0.200 .
66

77
### Preparation
88

@@ -30,10 +30,12 @@ cd browser-and-node/browser
3030
dotnet new wasmbrowser
3131
```
3232

33-
3. Replace generated HelloWorld-like `Program.cs` with HTTP-enabled one:
33+
3. Replace generated HelloWorld-like `Program.cs` and `wwwroot` contents with HTTP-enabled ones:
3434

3535
```sh
3636
cp ../Program.cs ./
37+
cp ../index.html ./wwwroot/
38+
cp ../main.js ./wwwroot/
3739
```
3840

3941
4. Compile the example:

browser-and-node/browser/wwwroot/main.js

-3
This file was deleted.

browser-and-node/browser/wwwroot/index.html renamed to browser-and-node/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>HTTP request for C# / .Net</title>
6-
<script type="module" src="../../main.js"></script>
6+
<script type="module" src="./main.js"></script>
77
</head>
88
<body>
99
<h2>HTTP Request from inside WASM using System.Net.Http.HttpClient</h2>

browser-and-node/node/README.md

+15-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Instructions for this devcontainer
44

5-
Tested with .Net version 8.0.100-rc.2.23502.2 .
5+
Tested with .Net SDK version 9.0.200, Bun 1.2.4, Deno 2.2.2, Node.js 22.14.0 .
66

77
### Preparation
88

@@ -28,17 +28,23 @@ cd browser-and-node/node
2828
2. Create new .Net project using `wasmconsole` template:
2929

3030
```sh
31-
dotnet new wasmconsole
31+
dotnet new wasmconsole -n NodeProject
3232
```
3333

3434
3. Replace generated HelloWorld-like `Program.cs` and `main.mjs` with HTTP-enabled ones:
3535

3636
```sh
37-
cp ../Program.cs ./
38-
cp ../main.js ./main.mjs
37+
cp ../Program.cs ./NodeProject/
38+
cp ../main.js ./NodeProject/main.mjs
3939
```
4040

41-
4. Compile the example:
41+
4. `cd` into the folder of the new .Net project to use it:
42+
43+
```sh
44+
cd NodeProject
45+
```
46+
47+
5. Compile the example:
4248

4349
```sh
4450
dotnet build
@@ -55,7 +61,7 @@ dotnet run
5561
Or, alternatively, the same by directly using `node` command:
5662

5763
```sh
58-
node bin/Debug/net8.0/browser-wasm/AppBundle/main.mjs
64+
node bin/Debug/net9.0/browser-wasm/AppBundle/main.mjs
5965
```
6066

6167
### Test with Bun
@@ -69,25 +75,23 @@ curl -fsSL https://bun.sh/install | bash
6975
2. Run with Bun:
7076

7177
```sh
72-
~/.bun/bin/bun bin/Debug/net8.0/browser-wasm/AppBundle/main.mjs
78+
~/.bun/bin/bun bin/Debug/net9.0/browser-wasm/AppBundle/main.mjs
7379
```
7480

7581
### Test with Deno
7682

7783
1. Install Deno:
7884

7985
```sh
80-
curl -fsSL https://deno.land/x/install/install.sh | sh
86+
curl -fsSL https://deno.land/install.sh | bash -s -- --yes
8187
```
8288

8389
2. Run with Deno:
8490

8591
```sh
86-
~/.deno/bin/deno run --allow-read --allow-net bin/Debug/net8.0/browser-wasm/AppBundle/main.mjs
92+
~/.deno/bin/deno run --allow-read --allow-net --unstable-bare-node-builtins bin/Debug/net9.0/browser-wasm/AppBundle/main.mjs
8793
```
8894

89-
You may want adding `Deno.exit();` to the end of `main.mjs`, in the case Deno does not exit after printing to console.
90-
9195
### Finish
9296

9397
Perform your own experiments if desired.

0 commit comments

Comments
 (0)