Skip to content

ActionNameAttribute

fonlow edited this page Feb 14, 2020 · 1 revision

By default, WebApiClientGen uses the name of a controller function for generating the client function name. If for some reasons you want to have a different name in the client API, you may use ActionNameAttribute to decorate the controller function.

	[Route("api/[controller]")]
	public class HeroesController : ControllerBase
	{
		/// <summary>
		/// Get all heroes.
		/// </summary>
		/// <returns></returns>
		[HttpGet]
		[ActionName("GetHeros")]
		public Hero[] Get()

Client codes generated:

		/// <summary>
		/// Get all heroes.
		/// GET api/Heroes
		/// </summary>
		public DemoWebApi.Controllers.Client.Hero[] GetHeros()
		{
			var requestUri = new Uri(this.baseUri, "api/Heroes");
Clone this wiki locally