我正在尝试进行扩展
public static ActionResult RedirectToIndexAction(this Controller controller)
{
return RedirectToAction("Index");
}
RedirectToAction("Index")
使RedirectToIndexAction();
答案 0 :(得分:1)
关于以下内容:
public static RedirectToRouteResult RedirectToAction<TController>(this Controller controller, Expression<Action<TController>> action, object routeValues) where TController : Controller
{
RouteValueDictionary routeValuesFromExpression = ExpressionHelper.GetRouteValuesFromExpression(action);
var routeValueDictionary = new RouteValueDictionary(routeValues);
foreach (KeyValuePair<string, object> keyValuePair in routeValueDictionary)
{
routeValuesFromExpression.Add(keyValuePair.Key, keyValuePair.Value);
}
return new RedirectToRouteResult(routeValuesFromExpression);
}
private RedirectToRouteResult RedirectToIndex()
{
return this.RedirectToAction<MyController>(c => c.Index(), new { Area = "" });
}