< h1 > <% = Html.Encode(ViewData["Message"]) %></h1>
< h2 > <% = Html.Encode(ViewData["Message"]) %></h2>
<% @ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<THB_MVC.Models.ViewDataHello>" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace THB_MVC.Models
{
public class ViewDataHello
public string HelloMsg { get; set; }
}
public ActionResult Hello(){
ViewDataHello msg = new ViewDataHello();
msg.HelloMsg = "Welcome to ASP.NET MVC!";
return View(msg);
< asp : Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Hello
</ asp : Content >
< asp : Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2><%= Model.HelloMsg %></h2>