Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom viewmodel in Umbraco
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>_Layout</title>
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace UmbSample.Models
{
public class MyModel
{
public string Title { get; set; }
}
}
@inherits UmbracoViewPage<UmbSample.Models.MyModel>
@{
Layout = "_Layout.cshtml";
}
Testing: @Model.Title
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Web.Mvc;
using UmbSample.Models;
namespace UmbSample.Controllers
{
public class umbHomepageController : Umbraco.Web.Mvc.RenderMvcController
{
public override System.Web.Mvc.ActionResult Index(Umbraco.Web.Models.RenderModel model)
{
return CurrentTemplate(new MyModel() { Title = model.Content.Name });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.