How to use @RenderPage to include CSS content inline - MVC Razor
I am currently exporting a page from my project into Excel which will not allow the linking of external content e.g. external CSS.
What I am trying to achieve is a simple way to include a CSS file in my
view but to have it called directly from a CSS file which will have automatically been minified by Visual Studio.
So, in my view I have tried this:
<style type="text/css"> @RenderPage("~/CSS/_ExportStyles.min.css") </style>
but doing this returns the following error:
Server Error in '/' Application.
The following file could not be rendered because its extension ".css" might not be supported: "~/CSS/_ExportStyles.min.css".
What I know will work would be to place the CSS in a normal
.cshtml file and include that, but I would lose the ability to
".min" the file which keeps the file size small and allows me to automatically strip out comments etc.
So, it turns out that
@RenderPage is not what I was looking for...
what I needed is this: