hamarb123
hamarb123
CC#
Created by hamarb123 on 6/13/2024 in #help
How to create files before main and pass command line args with net8.0-browser and wasm
I'm wanting to run a .net wasm app with files pre-created (before main function), and with command line arguments. Currently I can get command line arguments to work with dotnet.withApplicationArguments(...args).run(), but to create files beforehand, I need the module so I can access FS on it before running it to add the files, but whenever I do dotnet.create() it no longer gives me console output (it does still seem to give me the exit code though). For example, dotnet.create().then((x) => { return x.runMainAndExit(undefined, args) }).then((x) => console.log(x)) just prints 1. What am I doing wrong that I don't get console output from it? Please ping. Thanks!
8 replies
CC#
Created by hamarb123 on 4/12/2023 in #help
❔ Send using http post with multiple parameters, to an endpoint defined in C# with minimal APIs
I've got an endpoint like so:
app.MapPost("/endpoint1", async ValueTask<IResult?> (string param1, string param2) => ...);
app.MapPost("/endpoint1", async ValueTask<IResult?> (string param1, string param2) => ...);
But I can't work out how to get it to receive both parameters correctly when I try to send it from C#. Here's the latest one I tried:
var httpContent = new MultipartFormDataContent();
httpContent.Add(new StringContent(param1), "param1");
httpContent.Add(new StringContent(param2), "param2");
var result = await client.PostAsync("endpoint1", httpContent);
var httpContent = new MultipartFormDataContent();
httpContent.Add(new StringContent(param1), "param1");
httpContent.Add(new StringContent(param2), "param2");
var result = await client.PostAsync("endpoint1", httpContent);
I know it's not really supposed to get a form thing, but I have no idea which HttpContent type I should use, and I've tried a number of them now (potentially incorrectly, idk), so I thought I'd just ask what type I should use to send to the endpoint, and how to use it. I'm not overly familiar with http post in case you couldn't tell 😅. Thanks in advance Please ping or reply 🙂
8 replies