[英]IIS Express routing is not working properly in Visual Sudio 2019
我正在使用 Visual Studio 2019,當我通過IIS Express
運行解決方案並使用郵遞員向我的方法發送請求時,它返回404 狀態代碼。 但是當我在 PowerShell 中使用dotnet command
運行我的解決方案時,該應用程序正常工作並返回OK response 。
我認為我的代碼是正確的,因為當我使用dotnet command
運行它時它可以正常工作,但是我找不到解決此問題的方法。
我嘗試更改launchSettings.json
的 SSL 端口,我嘗試使用 http 和 https 發送請求,但它們都launchSettings.json
。 IIS Express
或Visual Studio
有什么問題嗎?
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
}
}
路由是http://localhost:6321/api/ContentManager/add和https://localhost:44444/api/ContentManager/add
您的特定情況的解決方案是更改launchSettings.json
的基本 URL。
"applicationUrl": "http://localhost:6321/"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.