dimanche 28 juin 2015

asp.net attribute routing No HTTP resource was found that matches the request URI

I am using asp.net mvc5 attribute routing as follows

[RouteArea("api")]
[RoutePrefix("data")]    
[Route("{action}")]
public class APIMasterDataController : Controller  

to achieve http://localhost/myapp/api/data/ ,

[RouteArea("api")]
[RoutePrefix("authentication")]
[Route("{action}")]
public class APIAuthenticationController : Controller

to achieve http://localhost/myapp/api/authentication/

and

[RouteArea("api")]
[RoutePrefix("transaction")]
[Route("{action}")]
public class APITransactionController : Controller

to achieve http://localhost/myapp/api/transaction/

But i am getting below error while accessing the url :

{"Message":"No HTTP resource was found that matches the request URI 'http://localhost/myapp/api/data/masters'.","MessageDetail":"No type was found that matches the controller named 'data'."}

I have added

routes.MapMvcAttributeRoutes();

in my RouteConfig file,

I have also updates Application_Start() with :

AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);

but I am still getting above mentioned error. What am I doing wrong / missing ?

Aucun commentaire:

Enregistrer un commentaire