我试图在我的Controller中定义一个RouteAttribute,但值始终为null。我试过的东西:
[HttpGet]
[Route("User/ChangePassword/{code:guid}")]
public ActionResult ChangePassword(Guid code)
{
return View();
}
URL:
http://localhost:59635/User/ChangePassword/c809619-4451-4e60-86ca-3bf7159c6d15
即使我放了一个字符串,我的代码总是为null。 PS。该参数是必需的,没有可选的,任何想法?
答案 0 :(得分:3)
确保在注册默认(或区域)路线之前注册属性路由。应该看起来像这样...
[2015-05-19 19:25:08] local.INFO: Writing to the log in 5 secs
[2015-05-19 19:25:10] local.INFO: Writing to the log in 10 secs