从 .net 3.5 升级到 4.0 后,MVC Html.ActionLink 不起作用
正如标题所说,我有一个带有一堆 Html.ActionLink 的项目
<%= Html.ActionLink("Reason for booking", "BookingReason")%>
,我已将项目升级到 .net 4.0,并且它们不再呈现指向操作的链接。当然,它只是一个空白,导致页面重新加载。
Html.ActionLink 标记位于区域共享文件夹中的用户控件 (ascx) 中。
我尝试再次降级到 .net 3.5 并且它有效 - 奇怪。有什么想法吗?
谢谢
Well as the title says, I have a project with a bunch of Html.ActionLink
<%= Html.ActionLink("Reason for booking", "BookingReason")%>
I have upgraded the project to .net 4.0 and they no longer render a link to the action. Its just a blank of course causing the page to reload.
The Html.ActionLink tags are in a user control (ascx) in the Shared folder of an Area.
I tried downgrading again to .net 3.5 and it works - weird. any ideas?
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请务必使用
UrlParameter.Optional
标记您的可选参数,这就是我们的问题(症状与您一样)。
——编辑
这不是唯一的问题。
当迁移到 MVC 3 时,你可能会遇到下一个问题,
假设您有这样的路线(
id
和page
是可选的),现在您必须将其拆分为 2 个不同的路线:
Be sure to mark your optional params with
UrlParameter.Optional
That was the problem for us (symptoms as yours).
-- Edited
It wasn't the only problem.
When migrating to MVC 3 you can get next problem,
suppose you had such route(
id
andpage
were optional)now you have to split it to 2 different routes:
排序了。
我需要在自定义路由之上有一条默认路由......必须在某个时候将其删除。
仍然很奇怪它在 .net 3.5 而不是 4 中的工作原理。
Sorted it.
I needed to have a default route above my custom ones...must have removed it at some point.
Still weird how it works in .net 3.5 and not 4.
你的问题就是我的答案..:)
那么工作的解决方案
<%= Html.ActionLink("Reason for booking", "BookingReason")%>
是<%= Html.ActionLink("预订原因", "BookingReason")%>
<%: Html.ActionLink("预订原因", "BookingReason")%>
差异:3.5 - "=" 和 4.0 - ":"
希望这也能解决您的问题..
Your question was the answer for me.. :)
Well the solution to work
<%= Html.ActionLink("Reason for booking", "BookingReason")%>
is<%= Html.ActionLink("Reason for booking", "BookingReason")%>
<%: Html.ActionLink("Reason for booking", "BookingReason")%>
Difference : 3.5 - "=" and 4.0 - ":"
Hope that solves your problem too..