How do I use Combres to embed the actual minified resource instead of a link?
-
12-10-2019 - |
Question
I'm writing an MVC view which will be sent as an HTML email. Since many mail clients don't render external CSS stylesheets, I need to include them inline. Since I'm already using Combres to combine and minify my stylesheets on the main site, I want to use it to insert the styles into my email view.
I could use Html.CombresLink("siteCss")
to render a <link>
to the minified stylesheet, but how do I render the actual CSS inline instead?
Solution
Currently, Combres doesn't support that. Given the fact that combined sets are usually large, I can't really see the reason why you would inline them. Externalizing them will use the browser cache efficiently while not doing so, you have to load the content every single time the page is loaded.
OTHER TIPS
You could always use the alternate method, CombresUrl("siteCss")
to get the URL to the combined and minified CSS, then use a WebClient
to request that URL and get the contents as a string, then include that in the email.
Yes, it adds a bit of overhead for the time taken to make the request, but it should work.