 <p>To return javascript to be executed directly in the client, like the Rails erb.js template, the best method would be to return a JavaScriptResult from the controller method</p> <pre><code>public ActionResult AjaxMethod() { /* do stuff */ return JavaScript(script); </code></pre> <p>}</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.javascriptresult.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.mvc.javascriptresult.aspx</a></p>