html.actionlink with .net 4.0 renders empty links
This should hopefully be a simple configuration problem.
When my application targets .Net 3.5
This code
<%= Html.ActionLink("Forgot your password?","ForgotPassword") %>
renders this:
<a href="/Account/ForgotPassword">Forgot your password?</a>
When my application targets .Net 4.0
The same code renders:
<a h开发者_Go百科ref="">Forgot your password?</a>
It's dropping the url part.
backwards compatibility is supposedly enabled in my web.config.
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
Ideas?
This had to do with the default map route having an extra value. It looks like .Net 4.0 is less forgiving about bad path mapping.
Solution for the following issues is very small. Please check your global.asax.cs file and change the line
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
to
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
Note: in MVC2.0 optional fields are marked through "UrlParameter.Optional".
I think this may solve your issues. If not then please update.
Thanks,
Kamal Kant Pansari
精彩评论