Rendering .html files as views in ASP.NET MVC

前端 未结 2 756
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 11:47

I would like to have .html files serve as views alongside other .cshtml views in my ASP.NET MVC project. The main reason for this is so that the html files are subject to th

2条回答
  •  臣服心动
    2020-12-30 12:23

    If you want to do it for one of your action method @Chris/ @Marius are awesome. as they given:

    return new FilePathResult("path_and_file.html", "text/html");
    //or better use
    return File("path_and_file.html", "text/html");
    

    I would like to add one more solution to the problem if you want to do it in web config to return pure html views from Views Folder:

    
    
    
    
    
    
    
    
    

    Here is a post suggesting it.

提交回复
热议问题