ScriptResourceHandler Class


提供處理指令碼檔案要求的 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. 您可以透過 ScriptingScriptResourceHandlerSection 類別的 EnableCompressionEnableCaching 屬性來關閉壓縮和快取。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.

(Inherited from Object)

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(Inherited from 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.


傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations


取得值,指出另一個要求是否可以使用 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.

Applies to