0

I have an ASP.NET Core web API; it's a simple rest interface.

In the project properties, I have this path:

Application Url

but when I start in the debugger, it always goes to:

http://localhost:58187/api/values

when the debugger loads Chrome, here is the url:

data:text/html;charset=utf-8,<head><meta http-equiv="refresh" content="0; url=http://localhost:58187/api/values"/></head><body><style>body{margin:25px;font:16px calibri,'segoe ui'}</style><h3>Chrome script debugging in Visual Studio is enabled</h3><ul><li>Set breakpoints in JavaScript/TypeScript in Visual Studio</li><li>Automatically break on script errors</li><li>Opening developer tools in Chrome stops the script debugging session</li></ul><a href='https://aka.ms/chromedebugging' target='_blank'>Learn more about Chrome debugging in Visual Studio</a><h4><i>Your application is starting...</i></h4></body><!---->

I can see the api/values string in the initial Url.

How do I change the api/values string?

1 Answer 1

3

The default launch path that is opened in the browser when you run or debug your application is configured in the Visual Studio launch settings. These can be configured in the Properties/launchSettings.json. In that file, there will be a section like this:

"profiles": {
  "profileName": {
    "commandName": "…",
    "launchBrowser": true,
    "launchUrl": "api/values",
    "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Development"
    }
  },
}

There might be more than one profile, usually there is at least one for “IIS Express” and one with the same name as your application. These profiles match the drop down you get from Visual Studio’s debug button (the one with the green play icon).

As you can see from the configuration, there is a launchUrl configuration which has the api/values value. This is the path that the browser will open by default. You can change this to whatever you like to make the browser go where you need it.

You could also create new launch profiles so you have different profiles for each of your main controllers or something. And of course, you could also just disable the launchBrowser setting to avoid the browser from opening every time, allowing you to open the site yourself (or just keep one tab open).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.