Open samdubey opened 5 months ago
Hi,
Actually SimpleW only support http
cause my use case was "everything behind an https reverse proxy", (ie: nginx).
Until recently, i will have to embed SimpleW with https
inside a C# android mobile app (the new xamarin.android rebranding).
I will look into this.
I have to decouple and refactor some class with interfaces to allow both NetCoreServer.HttpsServer
and NetCoreServer.HttpServer
use the Controller
class.
Back in a few days
Hi @samdubey could you please share a sample project with .net Maui and embedio recently I moved from Xamarin to Maui and I am using Embedio I am struggling to make it work after the upgrade
@samdubey
I just release v12.0.0 which now support https protocol.
As you can see in the documentation it requires very few line changes from the http mode.
I made a basic working REST API example inside a fresh .net MAUI application. Just unzip MauiApp1.zip :
MainPage.xaml.cs
fileResources\Raw\server.pfx
Run program and open up your browser to https://localhost:api/api/test (you need to bypass security and accept warning certificate cause it's self-signed).
Let me know if it is working for you
Hi @samdubey could you please share a sample project with .net Maui and embedio recently I moved from Xamarin to Maui and I am using Embedio I am struggling to make it work after the upgrade
string localhotUrl = string.Format("http://localhost:{0}", AppSettings.FreePort); Task.Factory.StartNew(async () => { //using (var server = new WebServer(HttpListenerMode.EmbedIO, "http://*:8080")) using (var server = new WebServer(HttpListenerMode.EmbedIO, localhotUrl)) { //Assembly assembly = typeof(App).Assembly; //server.WithLocalSessionManager(); server.WithWebApi("/api", m => m.WithController(() => new StreamController())); //server.WithEmbeddedResources("/", assembly, "XaPlay.html"); await server.RunAsync(); } });
this code goes at App.xaml.cs
and I am using following method to get FreeTcpPort across platform: Windows, Maccatalyst, iOS and Android
static int FreeTcpPort()
{
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
}
@samdubey
I just release v12.0.0 which now support https protocol.
As you can see in the documentation it requires very few line changes from the http mode.
I made a basic working REST API example inside a fresh .net MAUI application. Just unzip MauiApp1.zip :
- The main code is in the
MainPage.xaml.cs
file- self-signed certicate located in
Resources\Raw\server.pfx
Run program and open up your browser to https://localhost:api/api/test (you need to bypass security and accept warning certificate cause it's self-signed).
Let me know if it is working for you
It ran into error:
Dear Team,
I want to create and implement self-signed certificate (https) and to have local http server inside .NET MAUI app for android, ios, maccatalyst and windows platform
How do I achieve this with SimpleW, kindly guide me in right direction