2011-05-01 62 views

回答

1
public ActionResult Foo() 
{ 
    var model = ... 
    Response.ContentType = "text/javascript"; 
    return View(model); 
} 

Foo.cshtml

@model AppName.Models.SomeModel 
@{ 
    Layout = null; 
} 
var someProperty = @Html.Raw(Json.Encode(Model.SomeProperty)); 
alert(someProperty);