HttpRuntimeクラス

7465 ワード

HttpRuntimeはASP.NET処理要求では,HttpContextオブジェクトの作成とHttpApplicationFactoryの呼び出しによるHttpApplicationの作成を担当する.
定義は次のとおりです.
    public sealed class HttpRuntime

    {

        public HttpRuntime();

        //   System.Web.HttpRuntime                。

        public static string AppDomainAppId { get; }

        //

        public static string AppDomainAppPath { get; }

        //

        public static string AppDomainAppVirtualPath { get; }

        //   System.Web.HttpRuntime              。

        public static string AppDomainId { get; }

        //   ASP.NET              。

        public static string AspClientScriptPhysicalPath { get; }

        //   ASP.NET             。

        public static string AspClientScriptVirtualPath { get; }

        //     ASP.NET              。

        public static string AspInstallDirectory { get; }

        //          /bin        。

        public static string BinDirectory { get; }

        //          System.Web.Caching.Cache。

        public static Cache Cache { get; }

        //

        public static string ClrInstallDirectory { get; }

        //   ASP.NET              (    、        )        。

        public static string CodegenDir { get; }

        //     ,                    (UNC)   。          UNC   ,   true;  ,  false。

        public static bool IsOnUNCShare { get; }

        //          Machine.config            。

        public static string MachineConfigurationDirectory { get; }

        //     ,              IIS 7.0           。                ,   true;    false。

        public static bool UsingIntegratedPipeline { get; }

        //

        public static void Close();

        //            。System.Security.NamedPermissionSet   ,         ,   null。

        public static NamedPermissionSet GetNamedPermissionSet();

        //     ASP.NET Web     。  : wr:         System.Web.HttpWorkerRequest。

        public static void ProcessRequest(HttpWorkerRequest wr);

        //        。                 。

        public static void UnloadAppDomain();

    }

ここでは主にUnloadAppDomain()メソッドとCacheを選択します.
  1、HttpRuntime.Cache
  • HttpRuntime.Cacheはキャッシュの具体的な実装クラスに相当する、このクラスはSystemに置かれているが.Webネーミングスペースの下にあります.しかし、Webアプリケーションでなくても使えます.
  • HttpContext.Cacheは、上述したキャッシュクラスのカプセル化であり、HttpContextにカプセル化されているため、HttpContextを知っている限りでしか使用できない、すなわちWebアプリケーションにのみ使用できるようになっている.

  •   Page.CacheまたはHttpContext.Cache、実はすべてHttpRuntimeです.CacheのショートカットCacheはHttpContextにアクセスした.Cache,HttpContext.CacheはまたHttpRuntimeに直接アクセスした.Cache
      2、HttpRuntime.UnloadAppDomain()
    静的メソッドUnloadAppDomain()は、コードでWebサイトを再起動することができます.通常、ユーザがプログラムインタフェースを介して重要なパラメータを変更する場合に使用されます.この場合、プログラムを再起動する必要があります.