添加到页面的&LT CSS引用; HEAD>从局部视图 [英] Add CSS references to page's <head> from a partial view

查看:186
本文介绍了添加到页面的&LT CSS引用; HEAD>从局部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,以CSS引用从局部视图添加到页面,并让他们在渲染页面的< HEAD> (根据需要由 HTML 4.01规范)?

Is there a way to add CSS references to a page from a partial view, and have them render in the page's <head> (as required by the HTML 4.01 spec)?

推荐答案

您可以使用的HttpModule 处理响应HTML和移动任何CSS /脚本引用到合适的场所。这是不理想的,而我不知道的性能影响,但它似乎是唯一的方法来解决问题,而不是(a)基于JavaScript的解决方案,或(b)对MVC原则工作。

You can use a HttpModule to manipulate the response HTML and move any CSS/script references to the appropriate places. This isn't ideal, and I'm not sure of the performance implications, but it seems like the only way to resolve the issue without either (a) a javascript-based solution, or (b) working against MVC principles.

这篇关于添加到页面的&LT CSS引用; HEAD&GT;从局部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆