asp.net-mvc - 使用 asp.net mvc 重定向路由
问题描述
我是 MVC 的新手,所以请在这里帮助我。我需要重定向myhost.com/contactus
到myhost.com/aController/aView
.
我试过了
routes.MapRoute(
name: "contactus",
url: "contactus",
defaults: new { controller = "aController", action = "aView"}
);
但没有运气。我错过了什么:(
解决方案
你可以试试这个:
routes.MapRoute(
"contactus",
"{controller}/{action}/{id}",
new { controller = "aController", action = "aView", id = UrlParameter.Optional },
);
推荐阅读
- python - spacy-自定义标记化不适用于 POS 和 ORTH 和 OP 参数
- angular - 开放层以英里和反向计算范围的长度和宽度
- javascript - 将提取的文本返回到另一个 javascript 文件
- php - 当我将数组放入 foreach 循环时,我不断收到警告
- c++ - C++ 代码中的指针和 AVL 树存在问题
- batch-file - 指定要通过 .bat 文件打开的程序的确切路径
- python - 在 Gitlab 上运行时库的 Pylint E0401 导入错误
- column-oriented - 使用 docker-compose 将 mysql 作为元数据存储添加到 Apache-Druid
- javascript - 递归不保留javascript中的值
- reactjs - React CSS 过渡组:调用 Set State OnEntered 属性