Declare Controller

Declares an MVC controller for a string argument passed to the ActionLink, RenderAction or Action methods, referencing an undeclared controller. The action referenced from the same method call is automatically added to the generated controller class.

Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on an appropriate string argument passed to the ActionLink, RenderAction or Action methods.

Example

<%: Html.ActionLink("Test", "TestAction", "Test")%>

Result:

public class TestController : Controller
{
    public ActionResult TestAction()
    {
        return View();
    }
}
Public Class TestController
    Inherits Controller
    Public Function TestAction() As ActionResult
        Return View()
    End Function
End Class