1

I know this is a clone of the post ASP.net web api 2 Route-Attribute not working, but I am having another issue like this.

I can use the standard api routes if i configure this:

  // works just fine
  config.Routes.MapHttpRoute(
      name: "DefaultApi",
      routeTemplate: "api/{controller}/{id}",
      defaults: new { id = RouteParameter.Optional }
  );
  // does absolutley nothing

but the config.MapHttpAttributeRoutes(); seems to be doing absolutely nothing. No matter what i have tried so far helps.

Has anybody had this issue?

I have tried all the listed routes using the [Route()] attribute. Nothing works.

7
  • You should probably take a look at this to see where you went wrong learn.microsoft.com/en-us/aspnet/web-api/overview/… Commented Sep 11, 2017 at 22:40
  • Given that you have not really provided much to go on in terms of details there is way too many possibilities that could be the cause of your problem. You need to review How to Ask and then provide a minimal reproducible example. Commented Sep 11, 2017 at 22:42
  • Also note that config.MapHttpAttributeRoutes(); MUST come before convention-based routes. Commented Sep 11, 2017 at 22:45
  • 1
    I actually figured it out - there is an answer on the thread that I linked above by FrenchKevin777 - Verify that you are using System.Web.Http.RouteAttribute and not System.Web.Mvc.RouteAttribute Commented Sep 12, 2017 at 22:47
  • 2
    Possible duplicate of ASP.net web api 2 Route-Attribute not working Commented Sep 12, 2017 at 23:13

1 Answer 1

0

It turned out I was using the wrong namespace.

Must use : System.Web.Http.RouteAttribute What I Used : System.Web.Mvc.RouteAttribute The answer was posted on the thread which I referenced above - by ed FrenchKevin777

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

Comments

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.