Альтернативное решение с рамкой кодирования
Действие return json
Контроллер
[HttpGet]
public ActionResult SomeActionMethod()
{
return IncJson(new SomeVm(){Id = 1,Name ="Inc"});
}
Страница Razor
@using (var template = Html.Incoding().ScriptTemplate("tmplId"))
{
using (var each = template.ForEach())
{
Id: @each.For(r=>r.Id) Name: @each.For(r=>r.Name)
}
}
@(Html.When(JqueryBind.InitIncoding)
.Do()
.AjaxGet(Url.Action("SomeActionMethod","SomeContoller"))
.OnSuccess(dsl => dsl.Self().Core()
.Insert
.WithTemplate(Selector.Jquery.Id("tmplId"))
.Html())
.AsHtmlAttributes()
.ToDiv())
Действие return html
Контроллер
[HttpGet]
public ActionResult SomeActionMethod()
{
return IncView();
}
Страница бритвы
@(Html.When(JqueryBind.InitIncoding)
.Do()
.AjaxGet(Url.Action("SomeActionMethod","SomeContoller"))
.OnSuccess(dsl => dsl.Self().Core().Insert.Html())
.AsHtmlAttributes()
.ToDiv())