unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.45k stars 175 forks source link

Issue Serving Static Folder Xamarin ( 3.5.2) Forms on Android #591

Open lbabich opened 6 months ago

lbabich commented 6 months ago

I am currently trying to work with the sample for the Xamarin Forms but this seems to be using the older version. When creating a server and trying to serve up the HTML file for android I am getting a err_connection_refused when I try load up that URL. I have put the index.html file under Android/Assets/html also tried putting it in the root project folder under html. However I am somewhat unsure if this is just something I am missing?

protected override void OnStart()
        {
            var url = "http://127.0.0.1:9696";

            // // Our web server is disposable.
            using (var server = CreateWebServer(url))
            {
                server.RunAsync();
            }
        }
        private static WebServer CreateWebServer(string url)
        {
            var server = new WebServer(o => o.WithUrlPrefix(url));

            server.WithStaticFolder("/", "html", true, m => m
                .WithContentCaching(false));

            // server.StateChanged += (s, e) => $"WebServer New State - {e.NewState}".Info();

            return server;
        }
    public MainPage()
        {
            InitializeComponent();
            WebContent.Source = "http://127.0.0.1:9696/index.html";
        }