添加锚点到 RedirectToAction 的结果?
我正在尝试创建一个类似于 MVCContrib 的扩展方法RedirectToAction 方法,方法是创建一个采用 #anchor 参数并将其添加到 Url 的方法。我熟悉这个问题,但它不是强类型的。也可以将值添加到查询字符串,但这对于锚点不起作用。
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;
}
I'm trying to create an extension method similar to MVCContrib's RedirectToAction method by creating a method that will take an #anchor argument and add it to the Url. I am familiar with this question but it's not strongly typed. It's also possible to add values to the query-string, but that won't work for an anchor.
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论