Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / System.ServiceModel.Activation / System / ServiceModel / Activation / ServiceHttpModule.cs / 1305376 / ServiceHttpModule.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Activation { using System.Diagnostics; using System.Runtime; using System.Security; using System.ServiceModel; using System.Web; class ServiceHttpModule : IHttpModule { [Fx.Tag.SecurityNote(Critical = "Holds pointer to BeginProcessRequest which is SecurityCritical." + "This callback is called outside the PermitOnly context.")] [SecurityCritical] static BeginEventHandler beginEventHandler; //no need to invoke callback for non-WCF requests. static CompletedAsyncResult cachedAsyncResult = new CompletedAsyncResult(null, null); [Fx.Tag.SecurityNote(Critical = "This callback is called outside the PermitOnly context.")] [SecurityCritical] static EndEventHandler endEventHandler; static bool disabled; [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - called outside PermitOnly context.")] public void Dispose() { } [Fx.Tag.SecurityNote(Critical = "Entry-point from ASP.NET, accesses begin/bndProcessRequest which are SecurityCritical.")] [SecurityCritical] public void Init(HttpApplication context) { if (ServiceHttpModule.beginEventHandler == null) { ServiceHttpModule.beginEventHandler = new BeginEventHandler(BeginProcessRequest); } if (ServiceHttpModule.endEventHandler == null) { ServiceHttpModule.endEventHandler = new EndEventHandler(EndProcessRequest); } context.AddOnPostAuthenticateRequestAsync( ServiceHttpModule.beginEventHandler, ServiceHttpModule.endEventHandler); } [Fx.Tag.SecurityNote(Critical = "Entry-point from asp.net, called outside PermitOnly context. ASP.NET calls are critical." + "HostedHttpRequestAsyncResult..ctor is critical because it captures HostedImpersonationContext (and makes it available later) " + "so caller must ensure that this is called in the right place.")] [SecurityCritical] static public IAsyncResult BeginProcessRequest(object sender, EventArgs e, AsyncCallback cb, object extraData) { if (ServiceHttpModule.disabled) { return cachedAsyncResult; } try { ServiceHostingEnvironment.SafeEnsureInitialized(); } catch (SecurityException exception) { ServiceHttpModule.disabled = true; if (DiagnosticUtility.ShouldTraceWarning) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning); } // If requesting a .svc file, the HttpHandler will try to handle it. It will call // SafeEnsureInitialized() again, which will fail with the same exception (it is // idempotent on failure). This is the correct behavior. return cachedAsyncResult; } HttpApplication application = (HttpApplication) sender; // Check to see whether the extension is supported. string extension = application.Request.CurrentExecutionFilePathExtension; if (string.IsNullOrEmpty(extension)) { return cachedAsyncResult; } ServiceHostingEnvironment.ServiceType serviceType = ServiceHostingEnvironment.GetServiceType(extension); // do extension check first so that we do not need to do it in aspnetrouting/configurationbasedactivation if (serviceType == ServiceHostingEnvironment.ServiceType.Unknown) { return cachedAsyncResult; } // check for AspNetcompat if (ServiceHostingEnvironment.AspNetCompatibilityEnabled) { // remap httphandler for xamlx in CBA, since there is No physical file and // the xamlx httphandlerfactory will do file exist checking if (serviceType == ServiceHostingEnvironment.ServiceType.Workflow && ServiceHostingEnvironment.IsConfigurationBasedService(application)) { IHttpHandler cbaHandler = new ServiceHttpHandlerFactory().GetHandler( application.Context, application.Request.RequestType, application.Request.RawUrl.ToString(), application.Request.PhysicalApplicationPath); application.Context.RemapHandler(cbaHandler); } return cachedAsyncResult; } if (serviceType == ServiceHostingEnvironment.ServiceType.WCF) { return new HostedHttpRequestAsyncResult(application, false, false, cb, extraData); } if (serviceType == ServiceHostingEnvironment.ServiceType.Workflow) { return new HostedHttpRequestAsyncResult(application, false, true, cb, extraData); } return cachedAsyncResult; } [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - called outside PermitOnly context.")] static public void EndProcessRequest(IAsyncResult ar) { //No need to call CompletedAsyncResult.End as the asyncResult has already completed. if (ar is HostedHttpRequestAsyncResult) { HostedHttpRequestAsyncResult.End(ar); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Activation { using System.Diagnostics; using System.Runtime; using System.Security; using System.ServiceModel; using System.Web; class ServiceHttpModule : IHttpModule { [Fx.Tag.SecurityNote(Critical = "Holds pointer to BeginProcessRequest which is SecurityCritical." + "This callback is called outside the PermitOnly context.")] [SecurityCritical] static BeginEventHandler beginEventHandler; //no need to invoke callback for non-WCF requests. static CompletedAsyncResult cachedAsyncResult = new CompletedAsyncResult(null, null); [Fx.Tag.SecurityNote(Critical = "This callback is called outside the PermitOnly context.")] [SecurityCritical] static EndEventHandler endEventHandler; static bool disabled; [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - called outside PermitOnly context.")] public void Dispose() { } [Fx.Tag.SecurityNote(Critical = "Entry-point from ASP.NET, accesses begin/bndProcessRequest which are SecurityCritical.")] [SecurityCritical] public void Init(HttpApplication context) { if (ServiceHttpModule.beginEventHandler == null) { ServiceHttpModule.beginEventHandler = new BeginEventHandler(BeginProcessRequest); } if (ServiceHttpModule.endEventHandler == null) { ServiceHttpModule.endEventHandler = new EndEventHandler(EndProcessRequest); } context.AddOnPostAuthenticateRequestAsync( ServiceHttpModule.beginEventHandler, ServiceHttpModule.endEventHandler); } [Fx.Tag.SecurityNote(Critical = "Entry-point from asp.net, called outside PermitOnly context. ASP.NET calls are critical." + "HostedHttpRequestAsyncResult..ctor is critical because it captures HostedImpersonationContext (and makes it available later) " + "so caller must ensure that this is called in the right place.")] [SecurityCritical] static public IAsyncResult BeginProcessRequest(object sender, EventArgs e, AsyncCallback cb, object extraData) { if (ServiceHttpModule.disabled) { return cachedAsyncResult; } try { ServiceHostingEnvironment.SafeEnsureInitialized(); } catch (SecurityException exception) { ServiceHttpModule.disabled = true; if (DiagnosticUtility.ShouldTraceWarning) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning); } // If requesting a .svc file, the HttpHandler will try to handle it. It will call // SafeEnsureInitialized() again, which will fail with the same exception (it is // idempotent on failure). This is the correct behavior. return cachedAsyncResult; } HttpApplication application = (HttpApplication) sender; // Check to see whether the extension is supported. string extension = application.Request.CurrentExecutionFilePathExtension; if (string.IsNullOrEmpty(extension)) { return cachedAsyncResult; } ServiceHostingEnvironment.ServiceType serviceType = ServiceHostingEnvironment.GetServiceType(extension); // do extension check first so that we do not need to do it in aspnetrouting/configurationbasedactivation if (serviceType == ServiceHostingEnvironment.ServiceType.Unknown) { return cachedAsyncResult; } // check for AspNetcompat if (ServiceHostingEnvironment.AspNetCompatibilityEnabled) { // remap httphandler for xamlx in CBA, since there is No physical file and // the xamlx httphandlerfactory will do file exist checking if (serviceType == ServiceHostingEnvironment.ServiceType.Workflow && ServiceHostingEnvironment.IsConfigurationBasedService(application)) { IHttpHandler cbaHandler = new ServiceHttpHandlerFactory().GetHandler( application.Context, application.Request.RequestType, application.Request.RawUrl.ToString(), application.Request.PhysicalApplicationPath); application.Context.RemapHandler(cbaHandler); } return cachedAsyncResult; } if (serviceType == ServiceHostingEnvironment.ServiceType.WCF) { return new HostedHttpRequestAsyncResult(application, false, false, cb, extraData); } if (serviceType == ServiceHostingEnvironment.ServiceType.Workflow) { return new HostedHttpRequestAsyncResult(application, false, true, cb, extraData); } return cachedAsyncResult; } [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - called outside PermitOnly context.")] static public void EndProcessRequest(IAsyncResult ar) { //No need to call CompletedAsyncResult.End as the asyncResult has already completed. if (ar is HostedHttpRequestAsyncResult) { HostedHttpRequestAsyncResult.End(ar); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SafeArrayTypeMismatchException.cs
- PkcsMisc.cs
- TimelineGroup.cs
- MarkupCompilePass2.cs
- ReplyAdapterChannelListener.cs
- WebConfigurationFileMap.cs
- PersonalizableTypeEntry.cs
- BaseCollection.cs
- ReferentialConstraintRoleElement.cs
- ToolStripHighContrastRenderer.cs
- IxmlLineInfo.cs
- WebBrowserContainer.cs
- MediaPlayerState.cs
- SafeFileHandle.cs
- XmlNamespaceManager.cs
- MatrixConverter.cs
- ButtonStandardAdapter.cs
- TextRangeEdit.cs
- SqlClientFactory.cs
- SQLDecimal.cs
- BackgroundFormatInfo.cs
- ModifierKeysConverter.cs
- ReflectionPermission.cs
- PkcsMisc.cs
- ProxyWebPartConnectionCollection.cs
- ExitEventArgs.cs
- Stack.cs
- TouchPoint.cs
- LogicalChannelCollection.cs
- __Error.cs
- ParameterRefs.cs
- FrugalList.cs
- DrawingContextDrawingContextWalker.cs
- XPathScanner.cs
- DataGridViewAutoSizeModeEventArgs.cs
- WindowsListViewGroupSubsetLink.cs
- LinqTreeNodeEvaluator.cs
- Blend.cs
- RawStylusActions.cs
- MenuStrip.cs
- PenLineJoinValidation.cs
- EntityContainerAssociationSet.cs
- ViewGenResults.cs
- GenericsNotImplementedException.cs
- COM2ColorConverter.cs
- ToolboxBitmapAttribute.cs
- ContainsRowNumberChecker.cs
- SpinWait.cs
- ToolZone.cs
- Pair.cs
- ContainerUtilities.cs
- Condition.cs
- ReplacementText.cs
- DataColumnMapping.cs
- FixedSOMPageConstructor.cs
- TextFormatterHost.cs
- KnowledgeBase.cs
- _RequestCacheProtocol.cs
- ProgressBarBrushConverter.cs
- DataGridPageChangedEventArgs.cs
- ColumnCollection.cs
- IgnoreSection.cs
- ReliabilityContractAttribute.cs
- MapPathBasedVirtualPathProvider.cs
- ItemChangedEventArgs.cs
- DirectoryRootQuery.cs
- LinkButton.cs
- SymLanguageType.cs
- XmlElementAttributes.cs
- ValueQuery.cs
- PropertyEmitterBase.cs
- SystemTcpStatistics.cs
- XmlSerializerOperationGenerator.cs
- FileDetails.cs
- DefaultSection.cs
- XmlILConstructAnalyzer.cs
- WebServiceData.cs
- XhtmlTextWriter.cs
- OleDbParameter.cs
- UniqueConstraint.cs
- BeginStoryboard.cs
- BindingOperations.cs
- PartitionResolver.cs
- CodeMemberMethod.cs
- HttpProfileGroupBase.cs
- X509Extension.cs
- CachingHintValidation.cs
- CompoundFileStreamReference.cs
- TypeViewSchema.cs
- ObjectStateEntryDbDataRecord.cs
- ApplicationManager.cs
- ProgressBar.cs
- ScriptModule.cs
- DockProviderWrapper.cs
- TagPrefixAttribute.cs
- HelpEvent.cs
- ConstructorNeedsTagAttribute.cs
- TextPointerBase.cs
- DispatchChannelSink.cs
- TextWriterTraceListener.cs