I want to convert a .Net object in to JSON in the view. My view model is like this,
public class ViewModel{
public SearchResult SearchResult { get; set;}
This is an update to my original answer and I'll admit that as a result of the insistent badgering of @Tyrsius :D who refused to give up the fact that I could not access vars created in tags in my MVC 5 cshtml page from my .js libraries in separate files, I discovered that if I placed the script tags inside of the @section scripts statement block that the vars created there did make the global scope and was available to my plugin widgets. I have not used it within any of my more complex apps as of yet, but did use it in a protoType of another app and the answer is below. Now @Html.Raw(...) works and I was able to serialize an object that I could immediately use.
This is something I will be using from now on... thanks again for hanging in there with me @Tyrsius
@section scripts
{
@Scripts.Render("~/bundles/homeworkflow")
}
The following code is in a separate .js file
$(document).ready(function() {
alert(JSON.stringify(testVar));
});