using System;
using System.ComponentModel.DataAnnotations;
namespace HelloWorldMvcApp
{
public class SampleViewModel
public int X { get; set; }
public int Y { get; set; }
}
@model HelloWorldMvcApp.SampleViewModel
@{
Layout = null;
<!DOCTYPE html>
<html lang="en">
<body>
<canvas id="myCanvas" width="600" height="200"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.beginPath();
context.moveTo(0, 0);
context.lineTo(@Model.X, @Model.Y);
context.stroke();
</script>
</body>
</html>
using System.Web.Mvc;
using System.Collections.Generic;
public class HomeController : Controller
[HttpGet]
public ActionResult Index()
// todo populate viewModel from DB
return View(new SampleViewModel{X=200, Y=200});