Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Activation / ServiceHttpModule.cs / 1 / ServiceHttpModule.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Activation { using System.IO; using System.Text; using System.ServiceModel; using System.Web; using System.Web.Hosting; using System.Security; using System.Security.Permissions; using System.Diagnostics; class ServiceHttpModule : IHttpModule { ////// Critical - Holds pointer to BeginProcessRequest which is SecurityCritical. /// This callback is called outside the PermitOnly context. /// [SecurityCritical] static BeginEventHandler beginEventHandler; ////// Critical - This callback is called outside the PermitOnly context. /// [SecurityCritical] static EndEventHandler endEventHandler; static bool disabled; ////// RequiresReview - Called outside PermitOnly context, /// [SecurityRequiresReview] public void Dispose() { } ////// 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); } ////// 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 new CompletedAsyncResult(cb, extraData);; } 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 new CompletedAsyncResult(cb, extraData); } if (ServiceHostingEnvironment.AspNetCompatibilityEnabled) { return new CompletedAsyncResult(cb, extraData); } // Check to see whether the extension is supported. HttpApplication application = (HttpApplication) sender; string extension = System.IO.Path.GetExtension(application.Request.FilePath); if (extension == null || !ServiceHostingEnvironment.GetExtensionSupported(extension)) { return new CompletedAsyncResult(cb, extraData); } return new HostedHttpRequestAsyncResult(application, false, cb, extraData); } ////// RequiresReview - Called outside PermitOnly context, /// [SecurityRequiresReview] static public void EndProcessRequest(IAsyncResult ar) { if (ar is CompletedAsyncResult) { CompletedAsyncResult.End(ar); } else { HostedHttpRequestAsyncResult.End(ar); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CompressedStack.cs
- Int64KeyFrameCollection.cs
- UpWmlMobileTextWriter.cs
- WCFModelStrings.Designer.cs
- JulianCalendar.cs
- UnknownBitmapDecoder.cs
- M3DUtil.cs
- ProcessManager.cs
- IndicCharClassifier.cs
- ItemCollection.cs
- Color.cs
- NavigationWindowAutomationPeer.cs
- UInt32Storage.cs
- EncodingInfo.cs
- ProfilePropertySettings.cs
- HyperLinkStyle.cs
- ListViewGroupItemCollection.cs
- DateRangeEvent.cs
- IconHelper.cs
- IgnoreFlushAndCloseStream.cs
- AnnotationDocumentPaginator.cs
- SqlCacheDependencyDatabaseCollection.cs
- EncryptedKey.cs
- FixUp.cs
- Int32CAMarshaler.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- WorkflowRuntimeService.cs
- XmlDigitalSignatureProcessor.cs
- DataFormats.cs
- Serializer.cs
- SchemaCollectionPreprocessor.cs
- AtomMaterializerLog.cs
- HttpWriter.cs
- ErrorStyle.cs
- SoapCodeExporter.cs
- TemplatePagerField.cs
- MessageQueueException.cs
- ExpressionBindingCollection.cs
- ServiceOperationParameter.cs
- DefaultObjectSerializer.cs
- Transform3D.cs
- XmlSchemaType.cs
- EditorPart.cs
- XhtmlTextWriter.cs
- KeyboardEventArgs.cs
- UserInitiatedNavigationPermission.cs
- GuidConverter.cs
- CacheMemory.cs
- DWriteFactory.cs
- FixedSOMLineCollection.cs
- ObjectTypeMapping.cs
- VersionValidator.cs
- SqlCacheDependency.cs
- SessionEndingEventArgs.cs
- CollectionEditor.cs
- DropSource.cs
- TextEditorDragDrop.cs
- SQlBooleanStorage.cs
- SqlDataReaderSmi.cs
- Regex.cs
- Version.cs
- ApplicationBuildProvider.cs
- FormClosingEvent.cs
- ObjectCloneHelper.cs
- AnnotationMap.cs
- SoapTransportImporter.cs
- TargetControlTypeAttribute.cs
- Authorization.cs
- DirectoryInfo.cs
- FilteredXmlReader.cs
- WmfPlaceableFileHeader.cs
- FormsAuthenticationEventArgs.cs
- QuotedPrintableStream.cs
- EventlogProvider.cs
- ConstrainedGroup.cs
- RootProfilePropertySettingsCollection.cs
- PassportIdentity.cs
- PageMediaSize.cs
- XPathSelfQuery.cs
- ImageAnimator.cs
- ServerIdentity.cs
- GroupAggregateExpr.cs
- ReadOnlyDataSourceView.cs
- DatatypeImplementation.cs
- SafeHandles.cs
- BaseTemplateBuildProvider.cs
- WizardStepBase.cs
- TypeConverterHelper.cs
- MaxValueConverter.cs
- XmlArrayItemAttributes.cs
- DataGridViewColumn.cs
- DependencyPropertyKey.cs
- HtmlControlAdapter.cs
- Figure.cs
- LookupNode.cs
- Invariant.cs
- XmlQualifiedName.cs
- FindResponse.cs
- DurableInstanceProvider.cs
- TextBreakpoint.cs