Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Hosting / SimpleApplicationHost.cs / 4 / SimpleApplicationHost.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Hosting { using System; using System.Collections; using System.Configuration; using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Security.Permissions; using System.Web; using System.Web.Configuration; using System.Web.UI; using System.Web.Util; using Microsoft.Win32; using Debug = System.Web.Util.Debug; internal class SimpleApplicationHost : MarshalByRefObject, IApplicationHost { private VirtualPath _appVirtualPath; private String _appPhysicalPath; internal SimpleApplicationHost(VirtualPath virtualPath, string physicalPath) { if (String.IsNullOrEmpty(physicalPath)) throw ExceptionUtil.ParameterNullOrEmpty("physicalPath"); // Throw if the physical path is not canonical, to prevent potential // security issues (VSWhidbey 418125) if (FileUtil.IsSuspiciousPhysicalPath(physicalPath)) { throw ExceptionUtil.ParameterInvalid(physicalPath); } _appVirtualPath = virtualPath; _appPhysicalPath = StringUtil.StringEndsWith(physicalPath, "\\") ? physicalPath : physicalPath + "\\"; } public override Object InitializeLifetimeService() { return null; // never expire lease } // IApplicationHost implementation public string GetVirtualPath() { return _appVirtualPath.VirtualPathString; } String IApplicationHost.GetPhysicalPath() { return _appPhysicalPath; } IConfigMapPathFactory IApplicationHost.GetConfigMapPathFactory() { return new SimpleConfigMapPathFactory(); } IntPtr IApplicationHost.GetConfigToken() { return IntPtr.Zero; } String IApplicationHost.GetSiteName() { return WebConfigurationHost.DefaultSiteName; } String IApplicationHost.GetSiteID() { return WebConfigurationHost.DefaultSiteID; } public void MessageReceived() { // nothing } } [Serializable()] internal class SimpleConfigMapPathFactory : IConfigMapPathFactory { IConfigMapPath IConfigMapPathFactory.Create(string virtualPath, string physicalPath) { WebConfigurationFileMap webFileMap = new WebConfigurationFileMap(); VirtualPath vpath = VirtualPath.Create(virtualPath); // Application path webFileMap.VirtualDirectories.Add(vpath.VirtualPathStringNoTrailingSlash, new VirtualDirectoryMapping(physicalPath, true)); // Client script file path webFileMap.VirtualDirectories.Add( HttpRuntime.AspClientScriptVirtualPath, new VirtualDirectoryMapping(HttpRuntime.AspClientScriptPhysicalPathInternal, false)); return new UserMapPath(webFileMap); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Hosting { using System; using System.Collections; using System.Configuration; using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Security.Permissions; using System.Web; using System.Web.Configuration; using System.Web.UI; using System.Web.Util; using Microsoft.Win32; using Debug = System.Web.Util.Debug; internal class SimpleApplicationHost : MarshalByRefObject, IApplicationHost { private VirtualPath _appVirtualPath; private String _appPhysicalPath; internal SimpleApplicationHost(VirtualPath virtualPath, string physicalPath) { if (String.IsNullOrEmpty(physicalPath)) throw ExceptionUtil.ParameterNullOrEmpty("physicalPath"); // Throw if the physical path is not canonical, to prevent potential // security issues (VSWhidbey 418125) if (FileUtil.IsSuspiciousPhysicalPath(physicalPath)) { throw ExceptionUtil.ParameterInvalid(physicalPath); } _appVirtualPath = virtualPath; _appPhysicalPath = StringUtil.StringEndsWith(physicalPath, "\\") ? physicalPath : physicalPath + "\\"; } public override Object InitializeLifetimeService() { return null; // never expire lease } // IApplicationHost implementation public string GetVirtualPath() { return _appVirtualPath.VirtualPathString; } String IApplicationHost.GetPhysicalPath() { return _appPhysicalPath; } IConfigMapPathFactory IApplicationHost.GetConfigMapPathFactory() { return new SimpleConfigMapPathFactory(); } IntPtr IApplicationHost.GetConfigToken() { return IntPtr.Zero; } String IApplicationHost.GetSiteName() { return WebConfigurationHost.DefaultSiteName; } String IApplicationHost.GetSiteID() { return WebConfigurationHost.DefaultSiteID; } public void MessageReceived() { // nothing } } [Serializable()] internal class SimpleConfigMapPathFactory : IConfigMapPathFactory { IConfigMapPath IConfigMapPathFactory.Create(string virtualPath, string physicalPath) { WebConfigurationFileMap webFileMap = new WebConfigurationFileMap(); VirtualPath vpath = VirtualPath.Create(virtualPath); // Application path webFileMap.VirtualDirectories.Add(vpath.VirtualPathStringNoTrailingSlash, new VirtualDirectoryMapping(physicalPath, true)); // Client script file path webFileMap.VirtualDirectories.Add( HttpRuntime.AspClientScriptVirtualPath, new VirtualDirectoryMapping(HttpRuntime.AspClientScriptPhysicalPathInternal, false)); return new UserMapPath(webFileMap); } } } // 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
- BitFlagsGenerator.cs
- ScriptReferenceEventArgs.cs
- SoapAttributeOverrides.cs
- ToolBar.cs
- HtmlInputText.cs
- Rect3D.cs
- Psha1DerivedKeyGenerator.cs
- DesignerAutoFormatCollection.cs
- Dispatcher.cs
- CurrencyWrapper.cs
- PerformanceCounterPermissionEntry.cs
- DataFormat.cs
- ContentOperations.cs
- GatewayDefinition.cs
- StringCollection.cs
- ControlCollection.cs
- BinaryMethodMessage.cs
- fixedPageContentExtractor.cs
- TempFiles.cs
- ModelTreeEnumerator.cs
- PolyLineSegmentFigureLogic.cs
- DecoderNLS.cs
- CodeDefaultValueExpression.cs
- DbMetaDataFactory.cs
- ArrangedElement.cs
- HtmlEmptyTagControlBuilder.cs
- TrustManagerPromptUI.cs
- TypeInitializationException.cs
- ContainerControl.cs
- OleDbReferenceCollection.cs
- DataContractSerializerSection.cs
- TableLayoutSettingsTypeConverter.cs
- ScriptingSectionGroup.cs
- ViewLoader.cs
- BrowserCapabilitiesFactory35.cs
- DoubleCollection.cs
- AxParameterData.cs
- SHA256Managed.cs
- CompensationDesigner.cs
- WebPartAuthorizationEventArgs.cs
- BindingNavigator.cs
- Fonts.cs
- X509SecurityToken.cs
- GeneralEndpointIdentity.cs
- ArgIterator.cs
- TextServicesPropertyRanges.cs
- MouseActionValueSerializer.cs
- StateMachine.cs
- PngBitmapDecoder.cs
- ProfileSettings.cs
- SqlError.cs
- SubMenuStyle.cs
- AnimationClock.cs
- HtmlInputFile.cs
- SchemeSettingElementCollection.cs
- ProjectionAnalyzer.cs
- DataBinding.cs
- XmlSchema.cs
- VerificationException.cs
- BevelBitmapEffect.cs
- NonSerializedAttribute.cs
- ScrollProviderWrapper.cs
- TextBlockAutomationPeer.cs
- ThicknessAnimationUsingKeyFrames.cs
- XomlDesignerLoader.cs
- ImageButton.cs
- MethodCallTranslator.cs
- SystemResources.cs
- ActiveXSite.cs
- EventProviderBase.cs
- cache.cs
- PasswordRecovery.cs
- ValueQuery.cs
- ConfigurationException.cs
- ProxyGenerationError.cs
- Message.cs
- MessageSmuggler.cs
- HtmlInputReset.cs
- SystemKeyConverter.cs
- SimpleRecyclingCache.cs
- ValueSerializerAttribute.cs
- HyperLinkColumn.cs
- EventHandlerService.cs
- Encoder.cs
- NativeMethodsCLR.cs
- DocumentPageViewAutomationPeer.cs
- XmlQuerySequence.cs
- ClickablePoint.cs
- DecimalFormatter.cs
- FormsAuthenticationEventArgs.cs
- TextLineResult.cs
- StringInfo.cs
- ProcessModelInfo.cs
- TextElementEnumerator.cs
- ContainerUtilities.cs
- xamlnodes.cs
- HtmlControlAdapter.cs
- XmlSchemaComplexContentExtension.cs
- TableLayoutStyleCollection.cs
- Context.cs