簡體   English   中英

IIS Express 路由在 Visual Sudio 2019 中無法正常工作

[英]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 ExpressVisual 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/addhttps://localhost:44444/api/ContentManager/add

您的特定情況的解決方案是更改launchSettings.json的基本 URL。

"applicationUrl": "http://localhost:6321/" 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM