我正在尝试创建一个类似的扩展方法
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;
}