【发布时间】:2017-11-03 15:41:38
【问题描述】:
我正在学习asp.net,有一段时间不能解决一个比较简单的问题。
拥有包含以下内容的 RouteConfig.cs 文件:
public class RouteConfig {
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
并获得了带有内容的控制器:
...
[Route("image/show/{uuid}")]
public ActionResult Show(string uuid) {
return View(uuid);
}
...
And the result when I try to open this url
提前感谢您的回复!
【问题讨论】:
-
在属性路由中没有找到你接受的路径。
-
好的,但这是为什么呢?如果我将 Show fn-s 参数更改为 int,即:Show(int uuid)。然后相同的 url - 当然最后带有一个数字作为参数 - 可以正常工作,并且路由很好。所以在我看来问题的根本原因是参数类型是字符串...
标签: c# asp.net asp.net-mvc-4 routing