Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ambiguous reference System.Web.Http.RouteParameter

I am working on MVC5. I just Added a API Controller & facing error in WebApiConfig. The Error is- ambiguous reference system web http routeparameter. I don't understand from where Ambiguity is creating. Can any one please explain??

MyCode is:

using System.Web.Http;
namespace MyProject
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}
like image 701
Sarang K Avatar asked Dec 08 '22 04:12

Sarang K


1 Answers

I am done with the problem. The ambiguity for System.web.http is between System.Web.Http.Common & Microsoft.AspNet.WebApi.Core. I just removed System.Web.Http.Common from my solution as Microsoft.AspNet.WebApi.Core is doing the same stuff for me.

like image 141
Sarang K Avatar answered Mar 07 '23 11:03

Sarang K