【发布时间】:2020-02-09 22:53:41
【问题描述】:
我有以下路由表:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {controller = "Home", action = "Index", id = UrlParameter.Optional}
);
已经定义了许多控制器。 我已尝试将 URL 定向到控制器的操作,但这似乎不起作用。
因此,如果控制器是 DetailsController,我已将 URL 设置为以下内容:
http://localhost:<port number>/Details/Get
DetailsController中的Get定义如下:
[HttpGet]
[Route("")]
public async Task<HttpResponseMessage> Get()
它似乎没有重定向到那里,关于什么是错误的任何想法?
【问题讨论】:
-
你不需要这个
[Route("")]属性,删除它
标签: asp.net-mvc model-view-controller routes