?

Log in

Previous Entry | Next Entry

What isActionName and NoAction attribute?

ActionName
Normally we call public methods in controller as Action methods. Now many time it happens that we want to create actin methods which we will be available to external users with some different name. We can do that with the help of action name attributes.

Code
[ActionName("MyAction")]
publicActionResultActionMethod()
{
return View();
}
Advantages


  • Two action methods can be defined with same name now but exposed with 2 different name.

[ActionName("MyAction")]
publicActionResultActionMethod()
{
return View();
}
[ActionName("MyAction")]
publicActionResultActionMethod(int i)
{
return View();
}

  • ActionName may contain any special character it.

  • ActionName may start with number.

NoAction
It’s another useful attribute which can be used with ActionMethods.
We use this when we want to create public methods inside Controller but want to restrict user from access it via directly.
[NoAction()]
publicActionResultActionMethod()
{
return View();
}
server
Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

January 2017
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Tags

Powered by LiveJournal.com