S#arp ActionLinkForAreas +参数 +自定义路线 - 已更新!

发布于 2024-09-10 11:28:20 字数 513 浏览 0 评论 0原文

ActionLinkForAreas 链接扩展是否可以使用参数 + 自定义路由?

我有一条与我的操作匹配的路线,它是:

routes.MapRoute("Profile", "profile/{artist}/{action}", new {controller="Profile", action="Index"});

但是当我像这样调用 ActionLinkForAreas 时:

<%= Html.ActionLinkForAreas<ProfileController>(x => x.Index("DJ"), "DJ") %>

它返回 /profile/?artist=DJ ,因为我希望它在设置路线时返回 /profile/DJ 。

如果我调用 ActionLink,它会返回正确的 URL,我已在 Northwind 示例项目中对此进行了测试,并且得到了相同的结果。

我错过了什么吗?

Does the ActionLinkForAreas link extension work with parameters + custom routes?

I have a route that exists matching my action which is:

routes.MapRoute("Profile", "profile/{artist}/{action}", new {controller="Profile", action="Index"});

But when I call ActionLinkForAreas like this:

<%= Html.ActionLinkForAreas<ProfileController>(x => x.Index("DJ"), "DJ") %>

It returns /profile/?artist=DJ where as I would like it to return /profile/DJ as my route is setup.

If i call ActionLink it returns the correct URL, i have tested this in the Northwind sample project and I get the same result.

Am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪#恶を代价 2024-09-17 11:28:20

保罗,
您可能是对的,这是一个错误。也没有单元测试来测试这一点。现在我们正在重写 S#arp 架构,目前 1.5.2 中支持的区域将不会出现在 2.0 中。我们决定 100% 完全使用内置区域。如果我们必须添加自定义视图引擎,那将是因为需要覆盖区域位置。

由于我们正在开发 2.0,并且此功能即将消失,因此我必须诚实地说,我们很可能不会立即修复此功能。不过,我欢迎补丁,因为我相信其他人也会感激不已。

亚历克

Paul,
You might be correct that this is a bug. There are no unit tests to test this either. Right now we are in the middle of a re-write for S#arp Architecture and the areas support we currently have in 1.5.2 will not be in 2.0. We have decided to use the built-in areas 100% completely. If we have to add a custom view engine, it will be due to the need to override the area locations.

Since we are working on 2.0 and this feature is going away, I have to be honest and say that we most likely will not jump on this one to fix it. I would however welcome a patch as I am sure others would be grateful as well.

Alec

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文