This can be achieved by returning the ContentResult MSDN.
return Content("<script language='javascript' type='text/javascript'>alert('Hello world!');</script>");
or other way will use ajax
return json(new {message="hello"}); $.ajax({ url: URL, type: "POST", success: function(data){alert(data.message)}, });
din source share