Rename action method in ASP.NET MVC

How to rename action method?

To rename the Action method of the controller, we use ActionName attribute to the action method of the controller.
[ActionName("PersonList")]
  public ActionResult Index(string txtKeyword = null)
  {
     return View();
  }
Here, despite that our Action method name is Index, it will be accessible from the browser as PersonList.
Eg.  http://localhost:8888/PersonalDetails/PersonList (assuming that the controller name in which this action method exists is "PersonalDetails".

No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...