ViewBag
value is completely ignored while running ASP.NET MVC4 web page.
Here is the source for above image.
Even though I am checking if the ViewBag.SearchResultsJson
is null or empty, ViewBag still isn't written in the output.
<script>
@{
HtmlString jsonText = new HtmlString("");
if (!string.IsNullOrWhiteSpace(ViewBag.SearchResultsJson))
{
jsonText = Html.Raw(ViewBag.SearchResultsJson);
}
}
$(document).ready(function() {
var json = @jsonText;
app.value('searchResultsJson', json);
})
</script>
What am I missing here?