ASP.NET 使用为 Microsoft Edge 配置的 Visual Studio 2019 调试时的核心应用程序调试和开发?

ASP.NET Core application debug and development when debugging with Visual Studio 2019 configured for Microsoft Edge?

以下是有关我们开发环境的一些详细信息:

-DevExpress 20.2.3(我们正在使用 DevExtreme)

-Microsoft Visual Studio Enterprise 2019(版本 16.4.6)

-ASP.NET核心3.1.0

-AspNetCore.Mvc 3.1.0.0

我正在我公司办公网络上的开发 VDI 上进行开发。 当我在 Visual Studio 2019 年开发和调试有问题的应用程序代码时,我配置了调试模式以在 Microsoft Edge 中调试所述应用程序

内.........\launchSettings.json

{ "iisSettings": { "windowsAuthentication": true, "anonymousAuthentication": false, "iisExpress": { "applicationUrl": "http://localhost:18491", "sslPort": 44342 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, "nativeDebugging": true }, "InvestorCentral.Uploaders": { "commandName": "Project", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://localhost:5001;http://localhost:5000" } } }

在 ASP.NET 核心应用程序中,我的 .....\Startup.cs 有以下代码片段:

    public class Startup
    {
.....................
...............................
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHttpContextAccessor accessor)
        {
.........................
..................................

            app.UseEndpoints(endpoints =>
            {
.........................
..................................

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
.........................
..................................

但是,由于某些非常奇怪的原因,当我针对 Microsoft Edge 进行调试时,url 转到:

file:///C:/ProgramData/Microsoft/VisualStudio/EdgeAdapter/09227041/landingPage.html

如您所见,我们希望 启动 url/landing url 为 https://localhost:44342/Home/Index ,因此,我不知道为什么 Microsoft Edge 导航到启动 url/landing url 是:

file:///C:/ProgramData/Microsoft/VisualStudio/EdgeAdapter/09227041/landingPage.html

更奇怪的是,我办公室的某个内部服务器的登录凭据填写弹出框?

此外,这仅在 Visual Studio 调试配置为使用 Microsoft Edge 时发生,而不在 Chrome 中发生。

有人可以向我解释一下如何在使用 Microsoft Edge 进行调试时停止显示登录凭据填写弹出框吗?

这是正常行为。这是ChromeMicrosoft Edge之间的区别Chrome可以自动将您当前的用户名和密码添加到当前本地的web项目中,使其成为受信任的网站,从而获得访问该网站的权限。

但是,Edge没有这个功能。换句话说,它是由那个设计的。因为你在launchSettings.json文件中启用了windowsAuthentication,Edge无法自动访问你的信息,所以你每次调试web项目时都必须输入你的OS用户名和密码。

这就是两个浏览器的区别。所以其实这是我们常用的一点Chrome(更方便也更强大)

解决方案

要解决 Edge 的问题,您已将 anonymousAuthentication 设置为 true

它会自动将您的信息添加到网站中,以便您可以访问它。

感谢微软添加了这个有用的开关。当你使用Chrome时,你不必关心这个开关,它会自动添加你的信息,因为它的强大功能。