如何在asp.net mvc中检测响应内容类型
我编写了非常简单的缩小/压缩处理程序,通过指示请求类型(Request.RawUrl.EndsWith("css" || "js")
)来缩小 css 和 js,但我不知道一种指示哪种响应类型是 html 的方法,然后将其缩小为 HTML 内容,因为在 mvc 中不是检查的扩展。
提前致谢 ;)
I've wrote very simple minification/compression handler that minify css and js by indicating request type (Request.RawUrl.EndsWith("css" || "js")
), but i don't know an approach to indicate which response type is html and then minify that as HTML-content because in mvc isn't extension to checking.
thanks in advance ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您编写了 HTTP 处理程序来压缩静态资源您可以根据文件类型设置
Content-Type
标头:顺便说一句,我建议您提前缩小/压缩静态资源并依赖网络服务器的
gzip< /code> 压缩和客户端缓存。如果不是出于教育目的,我会避免编写此类处理程序。
If you wrote an HTTP handler to compress static resources it's up to you to set up the
Content-Type
header based on the file type:Btw I would recommend you to minify/compress your static resources in advance and rely on the web server's
gzip
compression and client caching. I would avoid writing such handlers if it's not education purposes.嗯...,我认为你误解了我的目标/问题。这是我的处理程序:
hm..., i think you misunderstood my goal/problem. here are my handler: