public class HomeController : Controller { string GetAbsUrl(string relativeUrl) { //REF: https://stackoverflow.com/a/9833745/ var ub = new UriBuilder(Request.Url.AbsoluteUri) { Path = Url.Content(relativeUrl), Port = Request.Url.IsDefaultPort ? -1 : Request.Url.Port }; return ub.ToString(); } public ActionResult Index() { WebClient wc = new WebClient(); var url = GetAbsUrl("~/Home/Api"); var str = wc.DownloadString(url); var report = new StringBuilder(); report.AppendLine("DownloadString=" + str); report.AppendLine("byte[]=" + BitConverter.ToString(Encoding.UTF8.GetBytes(str))); report.AppendLine("Encoding.Default=" + Encoding.Default.EncodingName); wc.Encoding = Encoding.UTF8; str = wc.DownloadString(url); report.AppendLine("DownloadString(Force UTF8)=" + str); return Content(report.ToString(), "text/plain"); } public ActionResult Api() { return Content("中文測試ABC", "text/html; charset=utf-8"); } }