In this part you will learn how to create a new controller action. You learn about the requirements of an action method.

Adding an Action to a Controller

You add a new action to a controller by adding a new method to the controller. For example, the controller in Listing 4 contains an action named Init() and an action named Login(). Both methods are public and exposed as actions.

Listing 4 : Controllers\contact\CustomController.cs

using System;
using System.Collections.Generic;
using System.Text;
using Koossery.MVCwin.Actions.itf;

namespace Koossery.MVCwin.Tuto.App_Code.controllers.contact
{
    public class CustomController : Koossery.MVCwin.Controller.impl.ControllerBase
    {
        public IActionResult Init()
        {
            return View(typeof(CustomView).Name);
        }

        public IActionResult Login()
        {
            return RedirectToAction(typeof(CustomController).Name, "Init");
        }
    }
}

Last edited Jun 19, 2009 at 4:53 PM by mohamadou, version 6

Comments

No comments yet.