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

AspNetCoreHosting example can run successfully with some small modifications #24

Open
tbebekis-ax opened this issue Jan 19, 2020 · 1 comment

Comments

@tbebekis-ax
Copy link

  1. Add a static public field to Webview class
    static public int Port = 0;

  2. Assign that field in the Main() getting the port value from the launchSettings.json

        public static void Main(string[] args)
        {
            Webview.Webview.Port = 11042; // <<<      

            CreateWebHostBuilder(args)
                .WithDynamicPort()
                .UseKestrel()
                .WithNoOutput()
                .Build()
                .RunWebview();
        }
  1. Modify the internal Webview constructor passing the Url

            string sUrl = $"http://localhost:{Port}"; // content.ToUri();            

            _webview = webview_alloc(
                title,
                sUrl,
                size.Width,
                size.Height,
                resizable ? 1 : 0,
                debug ? 1 : 0,
                cb);

PS. It seems that there is no way to get the "right" application url
using IServerAddressesFeature or any other trick.
If there is such a trick then I'll be happy to know.

@ghost
Copy link

ghost commented Jun 25, 2020

You need to use host.Start() to start Webhost before you can use IServerAddressesFeature to get the application url

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