I have created an Action in my Home Controller which accepts a text:
public class HomeController : Controller
{
public string DisplayText(string text)
{
return text;
}
}
I can call this Action, using the below url by passing the text parameter as a query string:
http://localhost:4574/Home/DisplayText?text=some text
However, I'd like to be able to call this using the below style:
http://localhost:4574/Home/DisplayText/some text
Therefore without specifying the parameter name ("text");
How would that be possible?
Another example to explain it more clearly is as below
public string Add(string a, string b)
{
return (int.Parse(a) + int.Parse(b)).ToString();
}
I can call it using:
http://localhost:4574/Home/Add?a=2&b=3
but how to call it in a RESTFul way? e.g. (http://localhost:4574/Home/Add/2/3)