title: Asp.net mvc passing a C# object to Javascript
body: <p>I have c# class say options more like AjaxOptions.</p>
  
  <pre><code>public class options
  {
     public string Url {get;set;}
     public string httpMethod {get;set}
  }
  </code></pre>
  
  <p>and a javascript function like this</p>
  
  <pre><code>function dosomething(obj)
  {
     if (obj.Url!="" and obj.HttpMethod=="something")
      loadsomething();
  
  }
  </code></pre>
  
  <p>Now in my Controller action </p>
  
  <pre><code> public class mycontroller : controller
   {
      public ActionResult WhatToDo()
      {
         options obj = new options{Url="someurl"};
         return PartialView(obj);
      }
  
  
   }
  </code></pre>
  
  <p>in my view I need this object kind of string which i should be able to pass to my method.</p>
  
  <pre><code>@model options
  
  &lt;script&gt;
     dosomething(@model.SomeFunctionToConverToString())
  
  &lt;/script&gt;
  </code></pre>
  
  <p>So I need this SomeFunctionToConverToString method which i will convert this object to string. </p>
  
  <p>Thanks</p>