1.

How To Change The Action Name In Mvc?

Answer»

“ActionName” ATTRIBUTE can be used for changing the action name.

Below is the sample CODE snippet to DEMONSTRATE more:

[ActionName("TestActionNew")]

PUBLIC ActionResult TestAction()

{

return View();

}

So in the above code snippet “TestAction” is the ORIGINAL action name and in “ActionName” attribute, name - “TestActionNew” is given. So the caller of this action method will use the name “TestActionNew” to call this action.

“ActionName” attribute can be used for changing the action name.

Below is the sample code snippet to demonstrate more:

[ActionName("TestActionNew")]

public ActionResult TestAction()

{

return View();

}

So in the above code snippet “TestAction” is the original action name and in “ActionName” attribute, name - “TestActionNew” is given. So the caller of this action method will use the name “TestActionNew” to call this action.



Discussion

No Comment Found