c# - asp.net core 3.1 更改路由
问题描述
有没有简单的方法来改变 asp.net core 3.1 控制器的路由?
目前我有控制器PicVideosController
URL: ...\picvideos... 并且我被要求将 URL 修改为 ...\picturesvideos...
我在控制器端添加了一条路线:
[Route("picturesvideos")]
public class PicVideosController : Controller
得到一个错误AmbiguousMatchException: The request matched multiple endpoints. Matches: Main.Controllers.PicVideosController.Pay (Main) Main.Controllers.PicVideosController.Completed (Main)
似乎仍然是在查看原始 url
解决方案
尝试这个:
[Route("picturesvideos/[action]")]
public class PicVideosController : Controller
{
[Route("/")]
[Route("~/picturesvideos")]
[Route("~/picturesvideos/index")]
public IActionResult Index()
....
推荐阅读
- react-native - 无法弄清楚为什么 React Hook 无效
- flutter - Flutter Visibility with Condition(如何只隐藏一个有条件的小部件)
- javascript - 如何在单击 javascript 时使用导航栏链接切换活动类
- javascript - 随着宽度变小,如何增加一个元素与另一个元素的距离?
- python - 检查 ping 命令
- python - pip 版本冲突(LooseVersion 是对的)
- javascript - 有没有办法直接从网站获取 Google Analytic 渠道?
- mysql - MySQL 或 MariaDB 的 REGEXP_REPLACE 不会使用通配符匹配替换空字符串
- google-chrome - Chrome 开发工具不会突出显示活动的 CSS 类
- java - JFrog Artifactory 中的 JAR 下载到 Gradle 缓存,但未显示在项目和外部依赖项中