Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Html.Raw used as attribute value in Razor is still being encoded [393]

$
0
0
Steps:
* Load an MVC 4 project.
* Go into a view (e.g., ~/Views/Shared/_Layout.cshtml).
* Add an attribute to an HTML element and make its value something that is already attribute-encoded and wrapped in `@Html.Raw`.
* Run site and find the title attribute is encoded, despite being run through `@Html.Raw`.

Example:
<a title="@Html.Raw("Show Size 6&#189;-8")">Test1</a>

Expected:
<a title="Show Size 6&#189;-8">Test1</a>

Actual (doubly-encoded somehow):
<a title="Show Size 6&amp;#189;-8">Test1</a>

[Original Stack Overflow question: http://stackoverflow.com/q/12321616/48700]
Comments: Yep, there's a bug here. I've got patched WebViewPage base classes here: https://gist.github.com/4036121 which can help work-around the problem. We'll put it on our queue for the next release!

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>