ITPub博客

首页 > IT职业 > IT图书 > HttpRuntime应用程序的运行时

HttpRuntime应用程序的运行时

IT图书 作者:qianby 时间:2021-09-09 09:46:48 0 删除 编辑

System.Web.HttpRuntime类是整个Asp.net服务器处理的入口。

这个类提供了一系列的静态属性,反映web应用程序域的设置信息,而且每个web应用程序域中存在一个System.Web.Runtime类。

图片描述

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace HttpRuntimeDemo{    public partial class _default : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            StringBuilder sb = new StringBuilder();            //应用程序域id            sb.AppendFormat("AppDomainAppId:{0}
", HttpRuntime.AppDomainAppId);            //web应用程序所在文件目录            sb.AppendFormat("AppDomainAppPath:{0}
", HttpRuntime.AppDomainAppPath);            //web应用程序的虚拟目录            sb.AppendFormat("AppDomainAppVirtualPath:{0}
", HttpRuntime.AppDomainAppVirtualPath);            //客户端脚本在服务器上的文件目录            sb.AppendFormat("AspClientScriptPhysicalPath:{0}
", HttpRuntime.AspClientScriptPhysicalPath);            //客户端脚本在服务器上的虚拟目录            sb.AppendFormat("AspClientScriptPhysicalPath:{0}
", HttpRuntime.AspClientScriptVirtualPath);            //asp.net安装目录            sb.AppendFormat("AspInstallDirectory:{0}
", HttpRuntime.AspInstallDirectory);            //bin目录            sb.AppendFormat("BinDirectory:{0}
", HttpRuntime.BinDirectory);            //clr安装目录            sb.AppendFormat("ClrInstallDirectory:{0}
", HttpRuntime.ClrInstallDirectory);            //生成代码的目录            sb.AppendFormat("CodegenDir:{0}
", HttpRuntime.CodegenDir);            //iss版本            sb.AppendFormat("IISVersion:{0}
", HttpRuntime.IISVersion.MajorRevision.ToString());            //本机配置文件所在的目录            sb.AppendFormat("MachineConfigurationDirectory:{0}
", HttpRuntime.MachineConfigurationDirectory);            //是否使用iis7集成模式            sb.AppendFormat("UsingIntegratedPipeline:{0}
", HttpRuntime.UsingIntegratedPipeline.ToString());            // Summary:            //     Gets a value that indicates whether the application is mapped to a universal            //     naming convention (UNC) share.            sb.AppendFormat("IsOnUNCShare:{0}
", HttpRuntime.IsOnUNCShare.ToString());            Response.Write(sb.ToString());                    }    }}

图片描述

上面列出了HttpRuntime主要的几个静态属性,输出结果为

图片描述

而HttpRuntime的静态方法ProcessRequest将帮助我们处理Http请求。

图片描述

        //        // Summary:        //     Drives all ASP.NET Web processing execution.        //        // Parameters:        //   wr:        //     An System.Web.HttpWorkerRequest for the current application.        //        // Exceptions:        //   System.ArgumentNullException:        //     The wr parameter is null.        //        //   System.PlatformNotSupportedException:        //     The Web application is running under IIS 7 in Integrated mode.        public static void ProcessRequest(HttpWorkerRequest wr);

图片描述

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3549/viewspace-2812183/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-08-27

  • 博文量
    75
  • 访问量
    21665