Search code examples
google-chromedebuggingvisual-studio-2019microsoft-edge

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


Here are some details about our development environment:

  • DevExpress 20.2.3 (we are using DevExtreme)

  • Microsoft Visual Studio Enterprise 2019 (Version 16.4.6)

  • ASP.NET Core 3.1.0

  • AspNetCore.Mvc 3.1.0.0

I'm developing on my Development VDI which is on my company's office network. As I develop and debug the application code in question within Visual Studio 2019, I configured the Debug mode to debug said application in Microsoft Edge: enter image description here

Within the ..........\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" } } }

In the ASP.NET Core application, my .....\Startup.cs has the following code snippet:

    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?}");
            });
.........................
..................................

However, for some really strange reason, when I debug for Microsoft Edge, the url goes to:

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

enter image description here

As you can see, we would expect the startup url/landing url to be https://localhost:44342/Home/Index , therefore, I have No idea why Microsoft Edge navigates to the the startup url/landing url to be:

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

Furthermore, it's even stranger that I get login credential fill-in popup box for some internal Server within our office.

And moreover, this only happens when Visual Studio debug is configured to use Microsoft Edge, and not in Chrome.

How can I go about Stop the login credential fill-in popup box from showing up when debugging using Microsoft Edge?


Solution

  • This is a normal behavior. And it is the difference between Chrome and Microsoft Edge. Chrome can automatically add your current username and password into the current local web project to make it as a trusted website so that you have the permission to access the website.

    However, Edge does not have this feature. In other words, it is designed by that. Because you have enabled windowsAuthentication in launchSettings.json file and Edge cannot access your info automatically, so you have to input your OS username and password each time to debug the web project.

    enter image description here

    This is the difference between the two browsers. So actually this is one point that we usually use Chrome(more convenient and powerful).

    Solution

    To solve the problem for Edge, you have set anonymousAuthentication to true.

    enter image description here

    It will automatically add your info into the website so that you can access it.

    Thanks for Microsoft that they has added this useful switch. When you use Chrome, you do not have to care about such switch and it will automatically add your info due to its powerful feature.