代码之家  ›  专栏  ›  技术社区  ›  mxmissile

向RedirectToAction的结果添加锚点?

  •  3
  • mxmissile  · 技术社区  · 14 年前

    我正在尝试创建一个类似的扩展方法 MVCContrib's RedirectToAction method 通过创建将接受#anchor参数并将其添加到Url的方法。我熟悉 this question 但它不是强类型的。也可以向查询字符串中添加值,但这对锚定不起作用。

    public static RedirectToRouteResult RedirectToAction<T>(this Controller controller, Expression<Action<T>> action, string anchor) where T : Controller
    {
       var result = new RedirectToRouteResult<T>(action);
    
       // how can I add the #anchor to the result's url?
    
       return result;
    }
    
    0 回复  |  直到 7 年前