I’m new to ASP.NET MVC 4. I’ve created an endpoint. That endpoint is available at:
/myController/actionName
In my controller, I have the following defined:
[HttpPost]
public void ActionName(string parameter1)
{
}
I am trying to figure out if its possible to have overloads. In ASP.NET MVC 4 Web API, is there a way for me to say something like the following:
[HttpPost]
public void ActionName(string parameter1)
{
}
[HttpPost]
public void ActionName(string parameter1, string parameter2)
{
}
If not, is there a way to make parameters optional?
Thank you!
You cannot overload controller actions, however, you can specify a parameter to be optional when defining your routing as follows: