c# - WebApi routing dependency using ASP.Net visual studio 2010 -


i'm creating wepapi on visual studio 2010, i've use nuget api. when i'm registering api in global file im getting following error. code below found in application_start of api.

protected void application_start(object sender, eventargs e)         {             log4net.config.xmlconfigurator.configure();             routetable.routes.maphttproute(                 name: "defaultapi",                 routetemplate: "api/{controller}/{id}",                 defaults: new { id = system.web.http.routeparameter.optional }             );         } 

the following error being given on $routetable.routes.maphttproute - instance argument:

cannot convert 'system.web.routing.routecollection' 'system.web.http.httproutecollection' 

any suggestions why error given?

you need use

globalconfiguration.configuration.routes.maphttproute 

instead of

routetable.routes.maphttproute 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -