JonathanManoharan-8874 avatar image
0 Votes"
JonathanManoharan-8874 asked JonathanManoharan-8874 commented

Issue with "launch URL" in launchsettings.json file of my ASP.Net Core project to create a REST API

I need to create a REST API simulating some typical bank operations. I have created an ASP.Net Core project and use a Code first approach with Entity Framework. I have successfully created the database and the REST CRUD functions.

I have two controllers in my project :- BankMembersController.cs and UserAccountsController.cs. I have attached the BankMembersController.cs file and launchSettings.json files.

In the launchSettings.json file, I have modified the "launchUrl" field to "api/bankMember" in the "profiles" and "Bank_Account" sections.

When I run the program using IIS Express and Google Chrome as the browser, a page renders with the following error information: for the URL https://localhost:44335/api/bankMember :-

Bad Request - Invalid Hostname
HTTP Error 400. The request hostname is invalid.

I have tried varios combinations for the "launchUrl" field e.g. BankMember, bankMembers, but all with same error message.

Further there is a second Controller call UserAccountsController. That is not currently mentioned in the launchsettings.json file.

Any help much appreciated!

· 12
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The launch setting should be set in the profiles section for IIS Express.

   "profiles": {
     "IIS Express": {
       "commandName": "IISExpress",
       "launchBrowser": true,
       "launchUrl": "api/bankMember",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"

The Bank_Account section is used when you change IIS Express to Bank_Account and run the project.


Keep in mind, launchSettings.json only applies to running the project from Visual Studio.

0 Votes 0 ·
capture.png (2.4 KiB)

Hi @Agavejoe,

The code that you listed is exactly the same as the text file I listed originally, so your suggestion won't make any difference. Thanks anyway. I have been running the project using IIS Express and know that the launchSettings.json file is only used for localhost development.

0 Votes 0 ·

Hi @JonathanManoharan-8874,

As far as I know, the HTTP Error 400. The request hostname is invalid. is not related with launch url, it is related with your IIS binding information. Could you please tell me where you hosted your application IIS express or you have hosted this application on IIS now. Could you please tell me if you directly run this application, is it working well ?

0 Votes 0 ·

Hi @BrandoZhang-MSFT

First let me thank you for helping me! Much appreciated. I thought it was the launch URL, even though all the resarch I've done says that the launch URL I set is correct.

IIS binding information:- I am developing this on my home desktop, so when I run the program it's localhost and I select the option IIS Express (google chrome is the web browser) and hit the play button.
So in answer to your question I believe I am running the application directly on my desktop using IIS Express as the web server. I'm not sure what you mean by IIS binding information. I am using the default settings for IIS Express.

Please give me some very specific questions, so we can resolve this. Once again thanks for your help!

0 Votes 0 ·
BrandoZhang-MSFT avatar image BrandoZhang-MSFT JonathanManoharan-8874 ·

Hi @JonathanManoharan-8874,

Could you please tell me if you remove the launchUrl settings and your web application will running well when you click the VS's start button?

0 Votes 0 ·
Show more comments

0 Answers