在 .NET 2.0,要將 .aspx 網頁中顯示的字串編碼時,要這樣寫: <%= HttpUtility.HtmlEncode(str) %> 到了 ASP.NET MVC 1.0,可以用 HtmlHelper 類別的 Encode 方法: <%= Html.Encode(ViewData["Message"]) %>... 轉貼: