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:
@Html.Raw(File.ReadAllText(Server.MapPath("~/CSS/_ExportStyles.min.css")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With