文章内容

2017/3/12 15:02:13,作 者: 黄兵

asp.net mvc 如何显示html

最近在mvc中显示html页面的时候显示404错误,后来经过查资料,找到了解决方案。

代码如下:

 // GET: BrandCenter
        public ActionResult Index()
        {
            //读取html文件内容
            using (StreamReader sr = new StreamReader(Server.MapPath("/Views/BrandCenter/Index.html")))
            {
                String htmlContent = sr.ReadToEnd();
                return Content(htmlContent);
            }
        }

之后打断点截图如下:

成功输出Html。

转载请注明出处。

分享到:

发表评论

评论列表