javascript views support for asp.net mvc 3
Is there any plugin or library that enables javascript views in asp.net mvc 3 such as the ones in rails where you put your javascrip开发者_JS百科t code in a view and then return it from the controller?
public ActionResult Foo()
{
var model = ...
Response.ContentType = "text/javascript";
return View(model);
}
and in Foo.cshtml
:
@model AppName.Models.SomeModel
@{
Layout = null;
}
var someProperty = @Html.Raw(Json.Encode(Model.SomeProperty));
alert(someProperty);
精彩评论