Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / UrlMappingsModule.cs / 1 / UrlMappingsModule.cs
namespace System.Web { using System; using System.Web; using System.Web.Util; using System.Web.Configuration; // // Module that implements the UrlMappings functionality // on IIS 7 in integrated mode, this takes the place of // the UrlMappings execution step and is listed insealed internal class UrlMappingsModule : IHttpModule { internal UrlMappingsModule() {} public void Init(HttpApplication application) { bool urlMappingsEnabled = false; UrlMappingsSection urlMappings = RuntimeConfig.GetConfig().UrlMappings; urlMappingsEnabled = urlMappings.IsEnabled && ( urlMappings.UrlMappings.Count > 0 ); if (urlMappingsEnabled) { application.BeginRequest += new EventHandler(OnEnter); } } public void Dispose() {} internal void OnEnter(Object source, EventArgs eventArgs) { HttpApplication app = (HttpApplication) source; UrlMappingsSection urlMappings = RuntimeConfig.GetAppConfig().UrlMappings; // First check RawUrl string mappedUrl = urlMappings.HttpResolveMapping(app.Request.RawUrl); // Check Path if not found if (mappedUrl == null) mappedUrl = urlMappings.HttpResolveMapping(app.Request.Path); if (!string.IsNullOrEmpty(mappedUrl)) //&& IsDifferentFromCurrentUrl(mappedUrl, app.Context)) app.Context.RewritePath(mappedUrl, false); } // private static bool IsDifferentFromCurrentUrl(string url, HttpContext context) // { // Uri absUri; // if (!Uri.TryCreate(url, UriKind.Absolute, out absUri)) // { // if (url.StartsWith("~/")) // url = UrlPath.Combine(context.Request.Path, url.Substring(2)); // if (!Uri.TryCreate(context.Request.Url, url, out absUri)) // return true; // } // return Uri.Compare(absUri, context.Request.Url, UriComponents.AbsoluteUri, UriFormat.UriEscaped, StringComparison.OrdinalIgnoreCase) != 0; // } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Web { using System; using System.Web; using System.Web.Util; using System.Web.Configuration; // // Module that implements the UrlMappings functionality // on IIS 7 in integrated mode, this takes the place of // the UrlMappings execution step and is listed in sealed internal class UrlMappingsModule : IHttpModule { internal UrlMappingsModule() {} public void Init(HttpApplication application) { bool urlMappingsEnabled = false; UrlMappingsSection urlMappings = RuntimeConfig.GetConfig().UrlMappings; urlMappingsEnabled = urlMappings.IsEnabled && ( urlMappings.UrlMappings.Count > 0 ); if (urlMappingsEnabled) { application.BeginRequest += new EventHandler(OnEnter); } } public void Dispose() {} internal void OnEnter(Object source, EventArgs eventArgs) { HttpApplication app = (HttpApplication) source; UrlMappingsSection urlMappings = RuntimeConfig.GetAppConfig().UrlMappings; // First check RawUrl string mappedUrl = urlMappings.HttpResolveMapping(app.Request.RawUrl); // Check Path if not found if (mappedUrl == null) mappedUrl = urlMappings.HttpResolveMapping(app.Request.Path); if (!string.IsNullOrEmpty(mappedUrl)) //&& IsDifferentFromCurrentUrl(mappedUrl, app.Context)) app.Context.RewritePath(mappedUrl, false); } // private static bool IsDifferentFromCurrentUrl(string url, HttpContext context) // { // Uri absUri; // if (!Uri.TryCreate(url, UriKind.Absolute, out absUri)) // { // if (url.StartsWith("~/")) // url = UrlPath.Combine(context.Request.Path, url.Substring(2)); // if (!Uri.TryCreate(context.Request.Url, url, out absUri)) // return true; // } // return Uri.Compare(absUri, context.Request.Url, UriComponents.AbsoluteUri, UriFormat.UriEscaped, StringComparison.OrdinalIgnoreCase) != 0; // } } } // 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
- MemberDomainMap.cs
- ProtocolViolationException.cs
- HttpBindingExtension.cs
- ActivitySurrogateSelector.cs
- UidPropertyAttribute.cs
- Attributes.cs
- AddInContractAttribute.cs
- ValidationVisibilityAttribute.cs
- SecurityIdentifierElement.cs
- ProcessProtocolHandler.cs
- DoubleLinkList.cs
- SHA512CryptoServiceProvider.cs
- SecurityElement.cs
- AspNetHostingPermission.cs
- SpecialNameAttribute.cs
- XamlPoint3DCollectionSerializer.cs
- CollectionViewGroup.cs
- EntitySqlQueryCacheEntry.cs
- RemotingConfiguration.cs
- NativeMethods.cs
- WorkflowInstanceExtensionCollection.cs
- OracleBinary.cs
- HandleRef.cs
- XsltArgumentList.cs
- ValidatingPropertiesEventArgs.cs
- AuthenticationServiceManager.cs
- UserPreferenceChangedEventArgs.cs
- CompilationUtil.cs
- FormDesigner.cs
- DbException.cs
- EventWaitHandleSecurity.cs
- TransformerInfoCollection.cs
- DesignObjectWrapper.cs
- KeyGestureValueSerializer.cs
- WorkflowControlEndpoint.cs
- TypeDescriptor.cs
- NumericPagerField.cs
- ServiceDiscoveryElement.cs
- RichTextBoxAutomationPeer.cs
- XmlSchemaObjectTable.cs
- SQLDateTimeStorage.cs
- StylusShape.cs
- DiffuseMaterial.cs
- ActiveXSite.cs
- AttachedAnnotation.cs
- xml.cs
- ViewBox.cs
- HttpDictionary.cs
- OdbcHandle.cs
- OutOfProcStateClientManager.cs
- DbExpressionVisitor_TResultType.cs
- SpnEndpointIdentity.cs
- SafeNativeMethods.cs
- FileDialog.cs
- ToolTipAutomationPeer.cs
- CodeExporter.cs
- VisualStateManager.cs
- Descriptor.cs
- LinkedResourceCollection.cs
- Validator.cs
- CalendarSelectionChangedEventArgs.cs
- SqlRecordBuffer.cs
- ApplicationSecurityInfo.cs
- namescope.cs
- X509Chain.cs
- BindingElement.cs
- RuleSetDialog.Designer.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- HttpException.cs
- PageBuildProvider.cs
- TextDataBindingHandler.cs
- DataGridSortCommandEventArgs.cs
- XsltSettings.cs
- IdnElement.cs
- EnumDataContract.cs
- TableLayoutPanelCellPosition.cs
- ComponentFactoryHelpers.cs
- Site.cs
- XamlVector3DCollectionSerializer.cs
- RandomNumberGenerator.cs
- CodeAttachEventStatement.cs
- FormParameter.cs
- SupportingTokenAuthenticatorSpecification.cs
- odbcmetadatacollectionnames.cs
- RoleManagerSection.cs
- ScaleTransform.cs
- DummyDataSource.cs
- COM2Properties.cs
- ContainerVisual.cs
- Span.cs
- SourceLocationProvider.cs
- PassportAuthentication.cs
- ReachFixedPageSerializer.cs
- Scripts.cs
- RegexTypeEditor.cs
- CapabilitiesPattern.cs
- OdbcEnvironmentHandle.cs
- ProcessingInstructionAction.cs
- URLMembershipCondition.cs
- FocusManager.cs