Including static html file from ~/Content into ASP.NET MVC view

后端 未结 6 1208
长情又很酷
长情又很酷 2020-12-16 14:18

I\'ve got master page in my project, which contains some information about site copyright and some contact info in it. I\'d like to take it out of master page and place it i

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 14:52

    For ASP .NET Core 3.1 Razor page you can do it like this:

    @Html.Raw(System.IO.File.ReadAllText("wwwroot/Content/snippet.html"));
    

    See documentation regarding static files here:

    https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-3.1

提交回复
热议问题