c# - IIS Express 路由在 Visual Sudio 2019 中无法正常工作
问题描述
我正在使用 Visual Studio 2019,当我通过 postman 运行解决方案IIS Express
并向我的方法发送请求时,它返回404 status code。dotnet command
但是当我在 PowerShell 中运行我的解决方案时,该应用程序可以正常运行并返回OK 响应。
我认为我的代码是正确的,因为当我使用 运行它时它可以正常工作dotnet command
,但是我找不到解决此问题的方法。
我试图更改 SSL 端口launchSettings.json
,我尝试使用 http 和 https 发送请求,但它们都不起作用。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
.
"applicationUrl": "http://localhost:6321/"
推荐阅读
- javascript - 如何在电子js应用程序的pdf中添加数字签名?
- typescript - Rxjs Observable 数组在给定的开始和结束值之间进行选择
- gitlab-ci - 动态设置 gitlab-ci cache.key
- java - 在java中将特定时区中给定的日期和时间转换为UTC的最佳方法是什么
- pine-script - Tradingview Multi Time Frame:如何在日线图上绘制每周高点?
- python - 如何在 Tensorflow 2 中更改策略
- gremlin - Gremlin 查询语言:如何删除每个没有边缘的顶点?
- amazon-web-services - graphql lambda API 网关给出内部服务器错误,无法在 CloudWatch 或 X 射线中捕获或记录异常
- firemonkey - FMX 中是否有 TStringGrid::SetEditText 的等价物?
- javascript - 如何在单个 Amcharts 折线图中将多个 CSV 文件加载到不同系列中