Gup3rSuR4c
Gup3rSuR4c

Reputation: 9490

ASP.NET MVC 5 @Html.Raw NOT Working with ▶

I have an ASP.NET MVC 5 app and I'm trying to display some content from the database that contains the BLACK RIGHT-POINTING TRIANGLE character (). MVC however is encoding it and changing it to â–¶.

I've tried using @Html.Raw, but it's not working. I also tried setting globalization in the Web.config as suggested in one of the answers to this question, also didn't help.

What can I do to output the character correctly? My response Content Type is text/html; charset=utf-8 if that matters, but I doubt it is what's affecting the output. Debugging the app before the model is handed off to the view, I can see that the character is correct, so it seems like the problem is coming from how Razor is rendering it?

Upvotes: 2

Views: 701

Answers (1)

Gup3rSuR4c
Gup3rSuR4c

Reputation: 9490

So, it turned out to be my HTML minification filter. It uses the HtmlAgilityPack and I wasn't passing the encoding when loading the stream. Turns out that's important to avoid issues like these. Now that I am passing the encoding, it works perfectly fine. Sorry to waste everyone's time since I figured it out 15 min after asking, but in case you're using the HtmlAgilityPack and you're getting wrong output, make sure you're telling it what the encoding is.

Upvotes: 2

Related Questions