如何在Visual Studio 2017中更改默认的调试浏览器?

4

我正在开发一个使用Topshelf作为服务托管的ASP.NET Core Web API项目。当我从调试器中启动服务时,Swagger页面会在Internet Explorer中打开。如何更改设置,使其在Chrome中打开?


我的WebApi项目是一个控制台应用程序,并使用Topshelf作为Windows服务托管。也许因为这个原因,我看不到IISExpress菜单。 - Anand
2个回答

10

从"开始调试"按钮开始,点击小箭头,然后按照以下步骤操作:

输入图像说明


我的WebApi项目是一个控制台应用程序,并使用Topshelf作为Windows服务托管,因此可能因此我看不到IISExpress菜单。 - Anand

-1
在这种情况下,从控制面板中选择默认浏览器。

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();
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接