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
- GroupBox.cs
- ComponentResourceManager.cs
- DecoderBestFitFallback.cs
- InputProcessorProfiles.cs
- UnknownBitmapDecoder.cs
- SiteMapDataSourceView.cs
- CodeDirectoryCompiler.cs
- TableDetailsRow.cs
- TypedElement.cs
- WebServiceData.cs
- GlyphInfoList.cs
- LineBreak.cs
- SafePointer.cs
- CodeDOMUtility.cs
- cryptoapiTransform.cs
- QuaternionValueSerializer.cs
- GridToolTip.cs
- JapaneseCalendar.cs
- FrameworkElementAutomationPeer.cs
- LinqDataSourceEditData.cs
- LineInfo.cs
- QueryRewriter.cs
- TimeSpan.cs
- Asn1IntegerConverter.cs
- Bidi.cs
- LongValidator.cs
- Menu.cs
- NamespaceQuery.cs
- ToolboxComponentsCreatingEventArgs.cs
- FilteredReadOnlyMetadataCollection.cs
- HierarchicalDataSourceControl.cs
- loginstatus.cs
- WebPartDisplayMode.cs
- OdbcEnvironmentHandle.cs
- DefaultValueAttribute.cs
- WebConfigurationHost.cs
- arclist.cs
- DoubleLinkListEnumerator.cs
- FloaterParaClient.cs
- VisualStyleTypesAndProperties.cs
- AppSettingsExpressionEditor.cs
- XPathNodeInfoAtom.cs
- ToolStripContainerActionList.cs
- DataGridPageChangedEventArgs.cs
- DataGridViewToolTip.cs
- AutomationPatternInfo.cs
- CompatibleIComparer.cs
- SqlParameterizer.cs
- PersonalizableAttribute.cs
- ControlPropertyNameConverter.cs
- UpdateTracker.cs
- ComplusTypeValidator.cs
- XmlSerializationReader.cs
- InstanceKeyView.cs
- TypeDescriptionProvider.cs
- EntityCommandCompilationException.cs
- ParseHttpDate.cs
- CharAnimationUsingKeyFrames.cs
- ClaimSet.cs
- HelpPage.cs
- DBBindings.cs
- OdbcRowUpdatingEvent.cs
- PerformanceCounterPermissionAttribute.cs
- Attributes.cs
- OperationCanceledException.cs
- ElementHostPropertyMap.cs
- XmlHierarchicalEnumerable.cs
- BaseResourcesBuildProvider.cs
- ApplicationFileCodeDomTreeGenerator.cs
- RuleCache.cs
- EncoderReplacementFallback.cs
- SendKeys.cs
- BuildProvider.cs
- WindowShowOrOpenTracker.cs
- XmlSchemaAll.cs
- ListViewItemMouseHoverEvent.cs
- _LocalDataStoreMgr.cs
- Tag.cs
- XPathEmptyIterator.cs
- SystemWebExtensionsSectionGroup.cs
- FigureParaClient.cs
- WebPartMenu.cs
- RelatedEnd.cs
- ChineseLunisolarCalendar.cs
- DataControlFieldCollection.cs
- FileNameEditor.cs
- PolicyReader.cs
- SQLString.cs
- HtmlTableCell.cs
- Int32CAMarshaler.cs
- ImportedNamespaceContextItem.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- VerticalAlignConverter.cs
- WebPartUserCapability.cs
- SecurityContextCookieSerializer.cs
- CategoryAttribute.cs
- FormsAuthenticationConfiguration.cs
- XmlAttribute.cs
- AssemblyBuilder.cs
- followingquery.cs