大陸北方網友
大陸北方網友

Reputation: 3767

How to access WebApi using "http"?

Now I created a WebApi and set its project url to https://localhost:44332/.

I can access it using url https://localhost:44332/api/test/get. But I also want to use http to access it, just like http://localhost:44332/api/test/get.

enter image description here

How do I configure the WebApi?

Upvotes: 0

Views: 50

Answers (1)

xakpc
xakpc

Reputation: 1809

Environment for local machine development can be set in the Properties\launchSettings.json file of the project.

If you launch your project with IISExpress you could setup which ports to use for https:// and http:// like this

"iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:59481",
      "sslPort": 44308
    }
  },

In this case, the application will be available on http://localhost:59481 and with SSL on https://localhost:44308. Please note that both endpoints could not have the same port (even in public web HTTP and HTTPS are on different ports, usually 80 and 443)

You could read more about the setup of the local environment here

Upvotes: 1

Related Questions