I'm using Visual Studio 2019, and when I run the solution by IIS Express
and send a request to my methods with postman, it returns a 404 status code . But when I run my solution using dotnet command
in PowerShell, the app works properly and returns an OK response .
I think my code is correct because it works correctly when I run it with dotnet command
, but I couldn't find a way to fix this problem.
I tried to change the SSL port in launchSettings.json
, I tried to send request using both http and https, but none of them worked. Is there any problem with IIS Express
or Visual Studio
or what?
launchSettings.json
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:6321/docs",
"sslPort": 44444
}
controller class
[Route("api/[controller]")]
public class ContentManagerController : Controller
{
[HttpPost]
[Route("add")]
public ContentManagerResponse AddSlider([FromBody]RequestClass request)
{
//some code
}
}
The routes are http://localhost:6321/api/ContentManager/add and https://localhost:44444/api/ContentManager/add
您的特定情况的解决方案是更改launchSettings.json
的基本 URL。
"applicationUrl": "http://localhost:6321/"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.