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 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This is an MVC 4 project, so there is no MapMvcAttributeRoutes. I got the GET attribute from here: link
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.