After upgrading my MVC 3 solution to MVC 4 with Razor 2 I came across the following problem.
This code in a view
@{
string main = "archive";
}
<div class="selected-@(main == "archive")"></div>
returns this in MVC 3
<div class="selected-True"></div>
and this in MVC 4
<div class="selected-class"></div>
which breaks my CSS.
Is that a bug introduced by the new conditional attribute feature in Razor 2?
My workaround is this:
<div class="selected-@((main == "archive").ToString())"></div>
which returns this:
<div class="selected-True"></div>
Does anyone have a better suggestion?