ScriptResourceHandler 类


提供用于处理作为资源而嵌入程序集的脚本文件请求的 HTTP 处理程序。Provides an HTTP handler for processing requests for script files that are embedded as resources in an assembly. 此类不能被继承。This class cannot be inherited.

public ref class ScriptResourceHandler : System::Web::IHttpHandler
public class ScriptResourceHandler : System.Web.IHttpHandler
type ScriptResourceHandler = class
    interface IHttpHandler
Public Class ScriptResourceHandler
Implements IHttpHandler


ScriptResourceHandler 类处理所有对通过 ScriptManager 类引用的嵌入脚本文件的请求。The ScriptResourceHandler class processes all requests for embedded script files that are referenced through the ScriptManager class. ScriptResourceHandler 对象检索嵌入的脚本库和脚本库的任何本地化资源。The ScriptResourceHandler object retrieves the embedded script library and any localized resources for the script library. 如果 NotifyScriptLoaded 属性设置为 true,则 ScriptResourceHandler 对象会将脚本文件末尾的调用添加到sys.databases对象的sys.application.notifyscriptloaded方法。If the NotifyScriptLoaded property is set to true, the ScriptResourceHandler object adds a call at the end of the script file to the notifyScriptLoaded method of the Sys.Application object.

默认情况下,ScriptResourceHandler 类压缩并缓存 Internet Explorer 7 嵌入的脚本文件。By default, the ScriptResourceHandler class compresses and caches embedded script files for Internet Explorer 7. 你可以通过 EnableCompressionEnableCaching ScriptingScriptResourceHandlerSection 类的属性来关闭压缩和缓存。You can turn compression and caching off through the EnableCompression and EnableCaching properties of the ScriptingScriptResourceHandlerSection class. 在 web.config 文件中设置这些属性。You set these properties in the Web.config file.


通过在 Web.config 文件的clientTarget节中创建 internet explorer 7 的别名,可以为 internet explorer 的早期版本启用压缩功能。You can turn compression on for earlier versions of Internet Explorer by creating an alias for Internet Explorer 7 in the clientTarget section of the Web.config file. 然后以编程方式将 ClientTarget 属性的值设置为该别名。You then programmatically set the value of the ClientTarget property to that alias. 但是,我们不建议使用此方法,因为这会导致性能降低,并导致错误的高风险。However, we do not recommend this approach because it will cause a decrease in performance and it introduces a high risk of errors.

启用 AJAX 的 ASP.NET Web 应用程序的默认 web.config 文件将 ScriptResourceHandler 添加为处理程序。The default Web.config file for AJAX-enabled ASP.NET Web applications adds the ScriptResourceHandler as a handler. 可以通过在 web.config 文件中包括以下元素,手动将处理程序添加到应用程序:You can manually add the handler to your application by including the following element in the Web.config file:

  <add verb="GET,HEAD" path="ScriptResource.axd"   
    System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,   
    PublicKeyToken=31bf3856ad364e35" validate="false" />  



初始化 ScriptResourceHandler 类的新实例。Initializes a new instance of the ScriptResourceHandler class.



当在派生类中重写时,获取一个指示其他请求能否使用该类实例的值。When overridden in a derived class, gets a value that indicates whether another request can use the instance of the class.



确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)

当在派生类中重写时,处理针对作为程序集内的资源而嵌入的脚本文件的 HTTP Web 请求。When overridden in a derived class, processes HTTP Web requests for a script file that is embedded as a resource in an assembly.


返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)



获取一个值,该值指示另一个请求是否可以使用 IHttpHandler 实例。Gets a value that indicates whether another request can use the IHttpHandler instance.


处理针对作为程序集内的资源而嵌入的脚本文件的 HTTP Web 请求。Processes HTTP Web requests for a script file that is embedded as a resource in an assembly.