In asp.net MVC [ActionName] attribte is an action selector which is used for providing different name to the action methods. When we want to call a action method using different name instead of its actual name then we use [ActionName] attribute. See the example below in which there is a action method original name 'Index',
using System;
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Mindstick.Controllers { public class HomeController : Controller { [ActionName('Home')] public ActionResult Index() { ViewBag.Message = 'Change the original method name by another name.';
return View('Index'); } } }
In the above example if we need to call the action method Index then provide a correct way is - http://localhost:12345/home/home.
If we use action method name Index instead of home then its throw 'server error in / Application'
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
[ActionName] Attribute :
In asp.net MVC [ActionName] attribte is an action selector which is used for providing different name to the action methods. When we want to call a action method using different name instead of its actual name then we use [ActionName] attribute. See the example below in which there is a action method original name 'Index',
In the above example if we need to call the action method Index then provide a correct way is - http://localhost:12345/home/home. If we use action method name Index instead of home then its throw 'server error in / Application'