How do you include .html or .asp file using razor?

后端 未结 14 1489
说谎
说谎 2020-12-14 01:09

Is it possible to use server side include in Razor view engine to include .html or .asp file? We have an .html file and .asp files that contain website menus that are used

14条回答
  •  自闭症患者
    2020-12-14 01:43

    Create a HtmlHelper extension method that gets the contents of the files:

    public static class HtmlHelpers
    {
      public static MvcHtmlString WebPage(this HtmlHelper htmlHelper, string url)
      {
        return MvcHtmlString.Create(new WebClient().DownloadString(url));
      }
    }
    

    Usage:

    @Html.WebPage("/serverside/menus/MainMenu.asp");
    

提交回复
热议问题