You must Sign In to post a response.
  • Category: ASP.Net MVC

    How to Enable Attribute Routing

    Hi Team,

    I am working on Visual Studio 2012, mvc 4,
    i want to Implement mvc 5 feature,Attribute Routing,for this i have written below code in routeConfig,
    but it is not supporting,

    but its giving below error

    Error 1 'System.Web.Routing.RouteCollection' does not contain a definition for 'MapMvcAttributeRoutes' and no extension method 'MapMvcAttributeRoutes' accepting a first argument of type 'System.Web.Routing.RouteCollection' could be found (are you missing a using directive or an assembly reference?)
    D:\Hari\RIS\RIS\App_Start\RouteConfig.cs 17 20 RIS
    can any help me pls for implementing attribute routing
  • #767285
    1. Try adding 'System.Web.Http' and 'System.Web.Mvc' namespace reference in RouteConfig.cs.
    If they are not available then Add Reference of 'System.Web.Http and System.Web.Http.WebHost.dll' first to your solution and then try above line.
    2. You had called routes.MapMvcAttributeRoutes(); i.e. you haven't passed RouteCollection/Routes as its argument, thats why you are getting this error.
    It must be MapMvcAttributeRoutes(RouteCollection).
    Please see its definition over here:

  • #767298

    I'm not sure about this but as per error details the method which you called as "MapMvcAttributeRoutes" is not part of this class "System.Web.Routing.RouteCollection" may be you missed to add references for this or the method it self is not available, request you to recheck whether the class contains that method or not.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #767302
    the above answers are not usefull to me

  • Sign In to post your comments