embedio
embedio copied to clipboard
Issue Serving Static Folder Xamarin ( 3.5.2) Forms on Android
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";
}