Introduction

A controller includes action methods that it can call in response to user interactions, such as clicking a link or submitting a form. Action methods have the following requirements:

  • An action method must return an ActionResult object. You do not have to instantiate an ActionResult object. That is performed for you by the action helper.

  • An action method must call one of the following action helpers as the return value, which are defined in the Controller class: View, Redirect, RedirectToAction, RedirectToRoute, Content, or Json.

To add an action method to an MVC controller

  1. Open the controller class that you want to add the new action method to.

  2. Add the following code, which defines an empty action method:


    [C#]
    public ActionResult MyAction()
    {
        // Enter logic here.
        return View();
    }
    
  3. Enter the logic for the action method.

  4. Save and close the file.


Technorati : asp.net mvc

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-06-29
  • 2021-08-26
  • 2022-12-23
猜你喜欢
  • 2021-07-08
  • 2021-11-03
  • 2022-03-07
  • 2022-12-23
  • 2021-08-21
  • 2021-11-28
  • 2021-10-13
相关资源
相似解决方案