Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / Hosting / SimpleApplicationHost.cs / 1 / 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
- FlowDocumentFormatter.cs
- BorderGapMaskConverter.cs
- BrowserTree.cs
- ToolStripDesignerUtils.cs
- MessageUtil.cs
- XmlSerializerSection.cs
- TableLayoutRowStyleCollection.cs
- ManifestResourceInfo.cs
- IncrementalCompileAnalyzer.cs
- ProgressPage.cs
- Pointer.cs
- XmlSchemaException.cs
- SymbolEqualComparer.cs
- InfoCardX509Validator.cs
- PowerStatus.cs
- SingleResultAttribute.cs
- SetterBaseCollection.cs
- WebInvokeAttribute.cs
- HostedImpersonationContext.cs
- SQLSingleStorage.cs
- baseshape.cs
- GridSplitterAutomationPeer.cs
- DrawListViewItemEventArgs.cs
- DbProviderFactories.cs
- HttpResponseHeader.cs
- ExeContext.cs
- ComNativeDescriptor.cs
- DataFormats.cs
- ComplexBindingPropertiesAttribute.cs
- NetMsmqBinding.cs
- XmlHelper.cs
- SpAudioStreamWrapper.cs
- SiteMapDataSource.cs
- BlurBitmapEffect.cs
- Form.cs
- XmlExpressionDumper.cs
- BooleanFunctions.cs
- CallbackValidator.cs
- StatusBar.cs
- SoapIncludeAttribute.cs
- COAUTHIDENTITY.cs
- UIElement3DAutomationPeer.cs
- ArrangedElement.cs
- XmlSerializerOperationGenerator.cs
- Compress.cs
- ProxyElement.cs
- Receive.cs
- FrameworkElement.cs
- BitmapCache.cs
- BaseProcessor.cs
- DiscoveryInnerClientManaged11.cs
- EventBuilder.cs
- BoundField.cs
- Subset.cs
- SqlUserDefinedTypeAttribute.cs
- dataprotectionpermission.cs
- FontCollection.cs
- CryptoStream.cs
- PieceDirectory.cs
- ManagementNamedValueCollection.cs
- XmlBinaryWriter.cs
- UrlPath.cs
- ObjectListCommandCollection.cs
- XmlSchemaSimpleContentExtension.cs
- HandlerFactoryWrapper.cs
- XmlSchemaInclude.cs
- LifetimeServices.cs
- COSERVERINFO.cs
- StateManager.cs
- path.cs
- PixelShader.cs
- Command.cs
- ErrorHandler.cs
- TimeSpan.cs
- ScrollProperties.cs
- HMACSHA512.cs
- CustomErrorsSectionWrapper.cs
- ContainerFilterService.cs
- LinkClickEvent.cs
- XmlNullResolver.cs
- TreeBuilder.cs
- XmlObjectSerializerWriteContext.cs
- _AutoWebProxyScriptEngine.cs
- ColumnMapTranslator.cs
- AnonymousIdentificationSection.cs
- BlurBitmapEffect.cs
- LocalBuilder.cs
- SqlBulkCopyColumnMapping.cs
- DependencyObjectType.cs
- UpdatableWrapper.cs
- TiffBitmapEncoder.cs
- PageCodeDomTreeGenerator.cs
- BindingValueChangedEventArgs.cs
- LateBoundBitmapDecoder.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- SecurityElement.cs
- FtpRequestCacheValidator.cs
- KeyGesture.cs
- TypeConverter.cs
- WebServiceMethodData.cs