0

I installed AttributeRouting via nuget, for an ASP.NET MVC 4 project, in which previously I mapped routes lowercase with a MapRouteLowercase extension, but I don't really think this could be causing the problem, because when I disabled my older route mappings in Global.asax, the attribute based routes were still not working.

[GET("Sample")]
public ActionResult Aszadba()
{
    ... do whatever
}

But when I check the routes.axd, the route is not present, nor it is working : (

Didn't touch any of the basic configurations that the package made at install. If I put a breakpoint into the AttributeRoutingConfig class it gets hit, so it seems the mapping function is called properly.

I also tried mapping with the [Route("Lofasz",HttpVerbs.GET)] format, without success.

Any help or hint would be appreciated!

1 Answers1

1

I believe you need to use the latter [Route(Directory/Page)] attribute syntax, although I haven't seen the Get attribute before and it may be a valid alternative.

Crucially you need to add-

 routes.MapMvcAttributeRoutes();

To your RouteConfig.cs file before your first mapped rotue.

pwdst
  • 13,909
  • 3
  • 34
  • 50
  • This is an MVC 4 project, so there is no MapMvcAttributeRoutes. I got the GET attribute from here: [link](http://attributerouting.net/#defining-routes) – seekingtheoptimal Nov 23 '13 at 17:57
  • Did you read the `Important Note` bit of that link? It may have some config code you need to execute in order to resolve your problem. – Jason Evans Dec 11 '13 at 11:30