我有以下问题:

routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler())
           Defaults = new RouteValueDictionary(
             new { controller = "Thread", action ="ShowThreadLastPostPage"}),
        Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" })
    }
);

有没有办法使用RedirectToAction方法导航到URL,如下所示:

forums/thread/{threadOid}/last#postOid

推荐答案

我认为你应该使用Redirect法和Url.RouteUrl法来完成它.

return Redirect(Url.RouteUrl(new { controller = "Thread", action = "ShowThreadLastPostPage", threadOid = threadId }) + "#" + postOid);

Asp.net相关问答推荐

无法从部署在应用程序负载均衡器后面的 AWS ECS 上的应用程序发送 HTTP/S 请求

如何在 ASP.NET RadioButtonList 中的项目之间添加空格

*不*使用 asp.net 会员提供程序是个坏主意吗?

从 Request.Url.AbsolutePath 获取应用相对 url

无法连接到 ASP.Net 开发服务器问题

Dotnet core 2.0 身份验证多模式身份 cookie 和 jwt

如何从网页 (asp.net) 启动 EXE

如何将 Castle Windsor 与 ASP.Net Web 表单一起使用?

不支持关键字:服务器

我可以在 Visual Studio 2010 中将任务列表项添加到 csHTML 吗?

带有邮箱地址参数的 WebApi 方法从 HttpClient 返回 404

System.Web.MVC 自 MS14-059 以来未复制到 bin 文件夹中.如何防止由于 Windows 更新而创建缺少 DLL 的构建?

SimpleMembership 与 ASP.NET MVC 4 中的自定义数据库架构

使用 Moq 验证活动注册

asp.net 有控制台日志(log)吗?

svg 无法在 localhost 上的 IIS 网络服务器上运行

*.csproj 中的 usevshostingprocess 是什么?

脚本管理器控制实际上是做什么的?

如何创建代表 colored颜色 的随机十六进制字符串?

如何在asp.net的GridView中按列名而不是按索引获取单元格值