A day with .Net

My day to day experince in .net

Multiple Get methods in Web API controller -Ninject.

Posted by vivekcek on September 28, 2013

When you have multiple get methods in a web api controller like below.

    public class WebApiController : ApiController
        private IMyInterface _iMyInterface = null;

        public WebApiController(IMyInterface iMyInterface)
            _iMyInterface = iMyInterface;

        public string GetName()
            return _iMyInterface.Name;

        public string GetTest()
            return _iMyInterface.Name;

Then you try to call ‘http://localhost:58956/api/WebApi/GetName‘ you may get an error like.

“ExceptionMessage”:”Multiple actions were found that match the request:


This is a simple route issue.The default route setting in WebApiConfig is shown below.


Change the above to.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s