开发者

MVC.Net HTML Encoding, IE7 vs other browsers

When I have this in my view

<a href="../Product/Category/<%= Html.Encode(item.Category) %>/Default.aspx?partial=False">
    <%= Html.Encode(item.Category)%></a>

It renders as expected in IE8 & FF

<a href="../Product/Category/Sauces%20&amp;%20Toppings/Default.aspx?partial=False">
    Sauces &amp; Toppings</a>

but does not render correctly in IE7

<a href="../Allergen/Category/Sauces &amp; Toppings/Default.aspx?partial=False">
    Sauces &amp; Toppings</a>

Specifically, it appers IE7 is decoding the href property value.

How do I 开发者_运维技巧get IE7 to render the encoded href?


You're using the wrong encoding.

You need to call Html.AttributeEncode(Url.Encode(item.Category)).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜