回顾一般处理程序
Posted Prozkb
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了回顾一般处理程序相关的知识,希望对你有一定的参考价值。
今天帮同学解答一个问题的时候,涉及到一般处理程序(末尾的链接讲了IHttpHandler 管道处理)了,之前在大三的时候接触过,以后再也没有接触过;现在做个笔记总价一下;
在一般处理程序里,有个IsReusable,百度翻译:可重用的
IsResuable属性指示是否可以重用于其他IHttpHandler实例;
如果设置为true,能提高性能,但要注意线程之间安全性问题 ;如果设置为false,则线程是安全的
一般情况下,都会设置成false,虽然不是性能最优,但是最安全(反正就是设置为false,就是保证安全之类的;)
1 public bool IsReusable 2 { 3 get 4 { 5 return false; 6 } 7 }
当我们打开一个网页的时候,不管请求的是静态的还是动态的资源,IIS会根据ISAPI(微软和Process软件公司联合提出的Web服务器上的API标准)这一标准,将请求的文件根据文件后缀名的不同,转 交给不同的处理程序。打开IIS可以看到,大部分文件都交给了aspnet_isapi.dll进行处理,但是aspnet_isapi.dll不可能对 所有文件都进行一样方式的处理。
为了了解aspnet_isapi.dll如何进行进一步处理的,我们可以打开C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\CONFIG\\Web.config文件。可以看到,在<httpHandler>节点中将不同的文件类型映射给不同的handler去处理;
1 <httpHandlers> 2 <add verb="*" path="*.rules" type="System.Web.HttpForbiddenHandler" validate="true"/> 3 <add verb="*" path="*.xoml" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false"/> 4 <add path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false"/> 5 <add path="trace.axd" verb="*" type="System.Web.Handlers.TraceHandler" validate="True"/> 6 <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True"/> 7 <add path="*.axd" verb="*" type="System.Web.HttpNotFoundHandler" validate="True"/> 8 <add path="*.aspx" verb="*" type="System.Web.UI.PageHandlerFactory" validate="True"/> 9 <add path="*.ashx" verb="*" type="System.Web.UI.SimpleHandlerFactory" validate="True"/> 10 <add path="*.asmx" verb="*" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="False"/> 11 <add path="*.rem" verb="*" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="False"/> 12 <add path="*.soap" verb="*" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="False"/> 13 <add path="*.asax" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 14 <add path="*.ascx" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 15 <add path="*.master" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 16 <add path="*.skin" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 17 <add path="*.browser" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 18 <add path="*.sitemap" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 19 <add path="*.dll.config" verb="GET,HEAD" type="System.Web.StaticFileHandler" validate="True"/> 20 <add path="*.exe.config" verb="GET,HEAD" type="System.Web.StaticFileHandler" validate="True"/> 21 <add path="*.config" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 22 <add path="*.cs" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 23 <add path="*.csproj" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 24 <add path="*.vb" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 25 <add path="*.vbproj" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 26 <add path="*.webinfo" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 27 <add path="*.licx" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 28 <add path="*.resx" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 29 <add path="*.resources" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 30 <add path="*.mdb" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 31 <add path="*.vjsproj" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 32 <add path="*.java" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 33 <add path="*.jsl" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 34 <add path="*.ldb" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 35 <add path="*.ad" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 36 <add path="*.dd" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 37 <add path="*.ldd" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 38 <add path="*.sd" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 39 <add path="*.cd" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 40 <add path="*.adprototype" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 41 <add path="*.lddprototype" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 42 <add path="*.sdm" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 43 <add path="*.sdmDocument" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 44 <add path="*.mdf" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 45 <add path="*.ldf" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 46 <add path="*.exclude" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 47 <add path="*.refresh" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/> 48 <add path="*" verb="GET,HEAD,POST" type="System.Web.DefaultHttpHandler" validate="True"/> 49 <add path="*" verb="*" type="System.Web.HttpMethodNotAllowedHandler" validate="True"/> 50 </httpHandlers> 51 52 <httpModules> 53 <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/> 54 <add name="Session" type="System.Web.SessionState.SessionStateModule"/> 55 <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/> 56 <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/> 57 <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/> 58 <add name="RoleManager" type="System.Web.Security.RoleManagerModule"/> 59 <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/> 60 <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/> 61 <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/> 62 <add name="Profile" type="System.Web.Profile.ProfileModule"/> 63 <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 64 <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 65 </httpModules>
1 <?xml version="1.0" encoding="utf-8"?><!-- the root web configuration file --><configuration> 2 <!-- 3 Using a location directive with a missing path attribute 4 scopes the configuration to the entire machine. If used in 5 conjunction with allowOverride="false", it can be used to 6 prevent configuration from being altered on the machine 7 8 Administrators that want to restrict permissions granted to 9 web applications should change the default Trust level and ensure 10 that overrides are not allowed 11 --> 12 <location allowOverride="true"> 13 <system.web> 14 <securityPolicy> 15 <trustLevel name="Full" policyFile="internal"/> 16 <trustLevel name="High" policyFile="web_hightrust.config"/> 17 <trustLevel name="Medium" policyFile="web_mediumtrust.config"/> 18 <trustLevel name="Low" policyFile="web_lowtrust.config"/> 19 <trustLevel name="Minimal" policyFile="web_minimaltrust.config"/> 20 </securityPolicy> 21 <trust level="Full" originUrl=""/> 22 </system.web> 23 </location> 24 25 <system.net> 26 <defaultProxy> 27 <proxy usesystemdefault="true"/> 28 </defaultProxy> 29 </system.net> 30 31 <system.web> 32 <authorization> 33 <allow users="*"/> 34 </authorization> 35 36 <browserCaps userAgentCacheKeyLength="64"> 37 <result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 38 </browserCaps> 39 40 <clientTarget> 41 <add alias="ie5" userAgent="Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)"/> 42 <add alias="ie4" userAgent="Mozilla/4.0 (compatible; MSIE 4.0; Windows NT 4.0)"/> 43 <add alias="uplevel" userAgent="Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)"/> 44 <add alias="downlevel" userAgent="Generic Downlevel"/> 45 </clientTarget> 46 47 <compilation> 48 <assemblies> 49 <add assembly="mscorlib"/> 50 <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 51 <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 52 <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 53 <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 54 <add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 55 <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 56 <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 57 <add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 58 <add assembly="System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> 59 <add assembly="*"/> 60 <add assembly="System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/> 61 <add assembly="System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/> 62 <add assembly="System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 63 <add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 64 <add assembly="System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 65 </assemblies> 66 <buildProviders> 67 <add extension=".aspx" type="System.Web.Compilation.PageBuildProvider"/> 68 <add extension=".ascx" type="System.Web.Compilation.UserControlBuildProvider"/> 69 <add extension=".master" type="System.Web.Compilation.MasterPageBuildProvider"/> 70 <add extension=".asmx" type="System.Web.Compilation.WebServiceBuildProvider"/> 71 <add extension=".ashx" type="System.Web.Compilation.WebHandlerBuildProvider"/> 72 <add extension=".soap" type="System.Web.Compilation.WebServiceBuildProvider"/> 73 <add extension=".resx" type="System.Web.Compilation.ResXBuildProvider"/> 74 <add extension=".resources" type="System.Web.Compilation.ResourcesBuildProvider"/> 75 <add extension=".wsdl" type="System.Web.Compilation.WsdlBuildProvider"/> 76 <add extension=".xsd" type="System.Web.Compilation.XsdBuildProvider"/> 77 <add extension=".js" type="System.Web.Compilation.ForceCopyBuildProvider"/> 78 <add extension=".lic" type="System.Web.Compilation.IgnoreFileBuildProvider"/> 79 <add extension=".licx" type="System.Web.Compilation.IgnoreFileBuildProvider"/> 80 <add extension=".exclude" type="System.Web.Compilation.IgnoreFileBuildProvider"/> 81 <add extension=".refresh" type="System.Web.Compilation.IgnoreFileBuildProvider"/> 82 &以上是关于回顾一般处理程序的主要内容,如果未能解决你的问题,请参考以下文章