How to use @RenderPage to enable inline CSS content - MVC Razor

I am currently exporting a page from my project to Excel, which will not allow linking external content, for example. external CSS.

What I'm trying to achieve is an easy way to include a CSS file in mine view, but call it directly from a CSS file that Visual Studio will automatically modify.

So, in my opinion, I tried this:

<style type="text/css">
   @RenderPage("~/CSS/_ExportStyles.min.css")
</style> 

but the following error is returned:

Server error in application "/".

The following file cannot be displayed because its extension ".css" may not be supported: "~ / CSS / _ExportStyles.min.css".

, , , CSS .cshtml , ".min" , ..

+4
1

, , @RenderPage , ...

:

@Html.Raw(File.ReadAllText(Server.MapPath("~/CSS/_ExportStyles.min.css")))

+16

Source: https://habr.com/ru/post/1524250/


All Articles