visual studio 2012 - Web API attribute routing HTTP 404 -


I can not make attribute routing to work in Web API 2. I did not start with the Web API template project, I think it was a blank project, Convention-based routing works, but when I add root attributes to controller functions, I get a 404 error. I get many posts about it, but None of them help me, it may be related to the project template, I have to do something manually since I have a lower project I did call in the WebApiConfig, call the MapHttpAttributeRoutes method, and Class Ehering API controller is public.What do I have to do in the WebApiConfig class and Application_Start method? thank you in advanced.

Here is my WebAPI config file:

  Public static zero registration (HTTP configuration configuration) {// Web API route configuration. MapHttpAttributeRoutes (); Config.routes.MapHttpRoute (name: "DefaultApi", MargTemplate: "API / {controller} / {action} / {oId} / {oTypeCode} / {oTypeName} / {email}", default: new {controller = "xrm ", Email = RootParameter Optional, OID = RootPamator. Optional, Autipod = RootPamator. Optional, Otipname = RootPamator. Optional]); }  

and application_Start method:

  Secure void Application_Start () {System.Web.Mvc.AreaRegistration.RegisterAllAreas (); GlobalConfiguration.Configure (WebApiConfig.Register); FilterConfig.RegisterGlobalFilters (GlobalFilters.Filters); RouteConfig.RegisterRoutes (RouteTable.Routes); Log4net.confiff.xmlConfigurator.Configure (); }  

Of course, my mistake is that I pass an email address as a path parameter Was trying. It is sent as a query string parameter, I'm not sure how it would want to send it as part of the path, but it works in this way for me.


Comments