Delen via


Controller.RedirectToAction Method (String, String)

Redirects to the specified action using the action name and controller name.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
Protected Friend Function RedirectToAction ( _
    actionName As String, _
    controllerName As String _
) As RedirectToRouteResult
protected internal RedirectToRouteResult RedirectToAction(
    string actionName,
    string controllerName
)
protected public:
RedirectToRouteResult^ RedirectToAction(
    String^ actionName, 
    String^ controllerName
)

Parameters

Return Value

Type: System.Web.Mvc.RedirectToRouteResult
The redirect result object.

Examples

The following example shows how to redirect to the Index action method in the Home controller.

public ActionResult LogOff() {
    FormsAuth.SignOut();
    return RedirectToAction("Index", "Home");
}
Function LogOff() As ActionResult
    FormsAuth.SignOut()
    Return RedirectToAction("Index", "Home")
End Function

See Also

Reference

Controller Class

RedirectToAction Overload

System.Web.Mvc Namespace