Pass data to view

CSharp · Mvc

Model

using System;
using System.ComponentModel.DataAnnotations;

namespace HelloWorldMvcApp
{
	public class SampleViewModel
	{
		
	}
}

View

@model System.DateTime

<!DOCTYPE html>

<html lang="en">
	<body>
		@Model.ToString()
	</body>
</html>

Controller

using System;
using System.Web.Mvc;
using System.Collections.Generic;

namespace HelloWorldMvcApp
{
	public class HomeController : Controller
	{
		[HttpGet]
		public ActionResult Index()
		{
			return View(DateTime.Now);
		}


	}
}
;