ScriptManager的Asp.Net的mvc [英] Scriptmanager Asp.Net Mvc

查看:129
本文介绍了ScriptManager的Asp.Net的mvc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一些在新的Asp.net MVC模式的ScriptManager特点:

I'd like to have some of the ScriptManager features in the new Asp.net MVC model:

1脚本合成结果
2 - 解决外部JavaScript文件结果不同的路径
3缩减大小和gzip的COM pression

1- Script combining
2- Resolving different paths for external Javascript files
3- Minify and Gzip Compression

这里是我发现了什么,但我不肯定是MVC方法的最佳途径。一般来说有什么好办法来处理在MVC模式的Javascript code?

Here is what I found, but I'm not sure is the best way for MVC approach. In general what is a good approach to deal with Javascript code in the MVC model?

推荐答案

也许你可以只创建具有不同的操作提供的COM $ P $的不同组合,一个新的脚本控制器pssed JS文件。由于MVC设计与资源为导向的方法,即现在的网址是在您的编程模型的中心,为什么不为你的Javascript定义简单的URI呢?

Maybe you could just create a new 'Scripts' controller with different actions serving different combinations of compressed JS files. Since MVC is designed with a resource oriented approach, i.e. URLs are now at the center of your programming model, why not define simple URIs for your Javascripts too ?

在您的看法,例如,你可以参考这样的文件:

In your views, for example you could reference your files like this :

<script src="http://your_domain/scripts/all"/>

这会叫你'所有'动作,导致被送到你所有的COM pressed脚本文件。

This would call your 'all' action, resulting in all your compressed script files being sent.

当然,你需要code合并和COM pressing现在,或者重复使用ScriptManager的内部,我不知道这是否是可能的。

Of course you would need to code the combining and compressing for now, or maybe reuse the Scriptmanager internally, I don't know if it's possible.

这只是一个想法,虽然,我目前在我的母版页直接引用单个JavaScript文件。

This is just an idea though, currently I'm referencing individual javascript files directly in my master pages.

这篇关于ScriptManager的Asp.Net的mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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