4

I am working on a ASP.NET Core Web API project that is hosted as a service using Topshelf. When I launch the service from debugger, the Swagger page comes up in Internet Explorer. How can I change so it is launched using Chrome?

Anand
  • 1,387
  • 2
  • 26
  • 48
  • Possible duplicate of [How do I set the default browser in Visual Studio 2017?](https://stackoverflow.com/q/49186787/113116), [Visual Studio opens the default browser instead of Internet Explorer](https://stackoverflow.com/q/79954/113116) – Helen Jul 19 '18 at 13:40
  • My WebApi project is a console application and it is hosed as Windows service using Topshelf, so maybe for that reason, I do not see the IISExpress menu – Anand Jul 19 '18 at 15:24

2 Answers2

10

From the start debugging button, click the small arrow, then do this:

enter image description here

Obay Abd-Algader
  • 1,079
  • 12
  • 25
  • My WebApi project is a console application and it is hosed as Windows service using Topshelf, so maybe for that reason, I do not see the IISExpress menu – Anand Jul 19 '18 at 15:23
-1

In this case the default browser is chosen from the control panel.

Control Panel

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="WebSiteBinding" value="http://localhost:63037"/>
<add key="Environment" value="LOCAL"/>
<add key="ServiceName" value="Debug"/>
<add key="ServiceDisplayName" value="Debug"/>
</appSettings>
</configuration>

class ApiService
{
    private string _url;
    private IWebHost _host;

    public void Start(string[] args)
    {
        _url = ConfigurationManager.AppSettings["WebSiteBinding"];

        _host = BuildWebHost(args);
        _host.Start();

#if DEBUG
        System.Diagnostics.Process.Start(_url);
#endif
    }

    public void Stop()
    {
        _host.Dispose();
    }

    public IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .UseNLog()
            .UseHttpSys(options =>
            {
                options.Authentication.Schemes = AuthenticationSchemes.NTLM;
                options.Authentication.AllowAnonymous = true;
                options.UrlPrefixes.Add(_url);
            })
            .Build();
}
Anand
  • 1,387
  • 2
  • 26
  • 48