如何使用 Combres 嵌入实际的缩小资源而不是链接?
我正在编写一个 MVC 视图,它将作为 HTML 电子邮件发送。由于许多邮件客户端不呈现外部 CSS 样式表,因此我需要将它们内联包含在内。由于我已经在使用 Combres 来组合和缩小主站点上的样式表,我想用它来将样式插入我的电子邮件视图中。
我可以使用 Html.CombresLink("siteCss")
将 渲染到缩小的样式表,但是如何渲染实际的 CSS 内联< /em> 代替?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前,Combres 不支持这一点。考虑到组合集通常很大,我真的不明白为什么要内联它们。外部化它们将有效地使用浏览器缓存,但如果不这样做,您必须在每次加载页面时加载内容。
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.
您始终可以使用替代方法
CombresUrl("siteCss")
获取组合且缩小的 CSS 的 URL,然后使用WebClient
请求该 URL 并获取内容作为字符串,然后将其包含在电子邮件中。是的,它增加了发出请求所需时间的一些开销,但它应该可以工作。
You could always use the alternate method,
CombresUrl("siteCss")
to get the URL to the combined and minified CSS, then use aWebClient
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.