Skip to main content

Action Selector in Asp.net Mvc

Action Selectors

Action selector are the attribute that applied to action method to handle a particular requests.
MVC 5 have following action selector attributes:

1) ActionName
2) NonAction
3) ActionVerbs


ActionName:

It allow us to specify different ActionName then the method name.


[ActionName("Student")]
public ActionResult StudentName(string stuName)
{
  
  return View();

}

In the above example, before specify [ActionName("Student")] , action method name was "StudentName" but after applying ActionName the new name of action method is "Student".



NonAction:

NonAction method indicates that the public method of a controller is not an action method. If you apply NonAction then it will not treat as a Method.



[NonAction]
public ActionResult StudentName(string stuName)
{
  
  return View();

}


ActionVerbs:

MVC framework support following ActionVerbs:

1) HttpGet
2) HttpPost
3) HttpPut
4) HttpDelete
5) HttpOptions
6) HttpPatch

In the next article we will learn about Models.

Click here to learn about Models


Comments

Popular posts from this blog

CRUD Operation in ASP.NET MVC Using ADO.NET Jquery Ajax

In this article of ASP.NET MVC we will learn about CRUD operation using jquery ajax so let's start. Firstly open visual studio: Go to File => New and Select Project,when you select project then New Project Dialogbox will appear. Select ASP.NET Web Application (.NET Framework) and give a name to your project , as we are building CRUD Operation so our project's name could be CRUD_OPEATION and then select OK. Now you will see a new dialogbox, select Empty Template and MVC folder. After create project you will see a like screen like this: Now go to Models folder and add ADO.NET Entity Data Model and give any name like in my case i give dbEntities and selec OK: After that you will see a dilogbox called Entity Data Model Wizard, select EF Designer from database and select Next: After that a new dilogbox will appear and it will ask a new connection to your sql server, then select New Connection and give server name ( if you want to see your server name then open sql server,it will ...

Jquery Fade

In this article we will learn about Jquery Fade: <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){   $("button").click(function(){     $("#div1").fadeIn();     $("#div2").fadeIn("slow");     $("#div3").fadeIn(3000);   }); }); </script> </head> <body> <button>Click me</button><br><br> <div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div> </body> </html>

Jquery - Css

In this article of Jquery we will learn about Css so Let's start. @{     ViewBag.Title = "Css"; } <!DOCTYPE html> <html> <head>     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>     <script src="~/js/CssClasses.js" type="text/javascript"></script>     <style>         .important{             font-weight :bold;             font-size:xx-large;         }         .blue{             color:blue;         }         .grey{           ...