我正在学习asp.net,并且无法解决一段时间内相当简单的问题。Asp.net MVC路由w /字符串参数
有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 - 在结束时使用一个数字作为参数 - 起作用,并且路由很好。所以在我看来,问题的根本原因是参数类型是字符串... – Joooe