How to serve html file from another directory as ActionResult

前端 未结 6 1637
长发绾君心
长发绾君心 2020-12-05 13:38

I have a specialised case where I wish to serve a straight html file from a Controller Action.

I want to serve it from a different folder other than the Views folder

6条回答
  •  孤街浪徒
    2020-12-05 13:54

    I want put my two cents in. I have found this most terse and it is there already :

    public ActionResult Index()
    {
         var encoding = new System.Text.UTF8Encoding();
         var html = ""; //get it from file, from blob or whatever
         return this.Content(html, "text/html; charset=utf-8");
    }
    

提交回复
热议问题