tags:

views:

204

answers:

2

When using Html.ActionLink passing a string containing the # char renders it like it is but if you UrlEncode it renders as %2523.

I believe it's a bug. MVC Beta Release.

Is it really a bug?

http://example.com/test# is rendered as

http://examplee.com/test%2523 instead of

http://examplee.com/test%2523

A: 

Are you passing in # as part of parameters of ActionLink? If so, you should just append it like this: Html.ActionLink("test") + "#"

ajma
+2  A: 

Not a bug :) You don't want to UrlEncode actual urls - UrlEncode helps you encode text within urls that might conflict with the URI control characters. In the same way, you wouldn't pass actual HTML into HtmlEncode unless you wanted to show your users the HTML itself.

Dan Finch