Mohan Subramanian

Mohan Subramanian

  • 1.5k
  • 168
  • 25.8k

MVC web api with GET and POST Method

Nov 27 2014 1:56 AM

Hi,

how to execute MVC web api method with different name but type is GET and POST. i can't able to execute. it shows error. here is my code.

webapiconfig.cs

           config.Routes.MapHttpRoute(            name: "DefaultApi",            routeTemplate: "api/{controller}/{id}",            defaults: new { action = "get", id = RouteParameter.Optional } );

Employee controller :

 [HttpGet] public string Test1() { return "this is a test1 string"; } [HttpGet] public string Test2() { return "this is a test2 string"; } [HttpPost] public string Test3() { return "this is a test3 string"; }

i want to execute both post and get all this method in different scenario. how to do it?


Answers (1)