Does anyone see why this controller/view code is rendering incorrectly?
Controller:
ViewBag.tempString = "some temp string";
...
Razor View:
<input id="tempJson" type="hidden" value="@Html.Raw(Json.Encode(ViewBag.tempString))" />
renders as:
<input id="tempJson" type="hidden" value some temp string"">
The value of @Html.Raw(Json.Encode(ViewBag.tempString))
is already a string. So try like this:
value= @Html.Raw(Json.Encode(ViewBag.tempString))