C# MVC 返回html内容

      var ss = Server.MapPath(""); //C:\Users\Administrator\Desktop\Csharp测试程序\TestMVC\TestMVC
            ss = ss + "/bin/index.html";
            using (StreamReader sr = new StreamReader(ss, System.Text.Encoding.GetEncoding("gb2312"))) //以gb2312编码方式读取
            {
                string htmlContent = sr.ReadToEnd();

                return Content(htmlContent);
            }
 //StreamReader sr = new StreamReader(path,Encoding.Default) //Encoding.Default 该编码方式没有gb2312

 

posted @ 2018-08-06 17:47  enych  阅读(3299)  评论(0编辑  收藏  举报