I've got the following controller:
public class HelloController
{
public ActionResult Index()
{
return View()
}
public ActionResult Hello()
{
return Json(new{ greeting = "hello, world!" }, JsonRequestBehavior.AllowGet);
}
}
Then, inside Index.cshtml
:
...html stuffs
<script type="text/javascript">
alert("@Html.Action("Hello")");
</script>
What I'm finding is that, when going to this url in my browser, the response content type is application/json; charset=utf-8
which causes the browser to render the html as a string instead of as... a web page.
What's the best way to get around this?