3

Im trying to define a RouteAttribute in my Controller but the value is always hitting null. Stuff i tried:

 [HttpGet] [Route("User/ChangePassword/{code:guid}")] public ActionResult ChangePassword(Guid code) { return View(); } URL: http://localhost:59635/User/ChangePassword/c809619-4451-4e60-86ca-3bf7159c6d15 

Im getting this code always null, even if i put a string. Ps. The parameter is required and no optional, any ideas?

2
  • And your URL looks like this? http://yoursite/user/changepassword/12345678-1234-1234-1234-123456789012 Commented May 19, 2015 at 19:26
  • @NickAlbrecht yes, thats it Commented May 19, 2015 at 19:34

1 Answer 1

3

Make sure your call to register the attribute routes comes before you register the default (or area) routes. Should look something like this...

routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); AreaRegistration.RegisterAllAreas(); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.