Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lbabich opened this issue Feb 15, 2024 · 0 comments
Open

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

lbabich opened this issue Feb 15, 2024 · 0 comments

Comments

@lbabich
Copy link

lbabich commented Feb 15, 2024

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";
		}
@lbabich lbabich changed the title Issue Serving Static Folder Xamarin Forms Android 3.5.2 Issue Serving Static Folder Xamarin ( 3.5.2) Forms on Android Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant