Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Hosting / SimpleApplicationHost.cs / 1305376 / 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
- AnnotationComponentChooser.cs
- ValidationHelper.cs
- ObjectAssociationEndMapping.cs
- SafeReadContext.cs
- EventLogQuery.cs
- SqlDependency.cs
- AnnotationResourceCollection.cs
- CompositeDataBoundControl.cs
- KernelTypeValidation.cs
- AssertHelper.cs
- X509Chain.cs
- XmlSchema.cs
- NameValueFileSectionHandler.cs
- ComponentGlyph.cs
- WorkflowMarkupSerializerMapping.cs
- QilList.cs
- VariableReference.cs
- DataColumnChangeEvent.cs
- SettingsAttributeDictionary.cs
- DataPagerFieldItem.cs
- OleDbWrapper.cs
- HtmlGenericControl.cs
- PkcsMisc.cs
- DrawingGroup.cs
- SecureConversationSecurityTokenParameters.cs
- ElementHostPropertyMap.cs
- XmlSerializerObjectSerializer.cs
- SystemResourceKey.cs
- ConfigXmlCDataSection.cs
- WorkflowMarkupElementEventArgs.cs
- EncoderFallback.cs
- ReferenceAssemblyAttribute.cs
- HandleTable.cs
- ImageAutomationPeer.cs
- HttpWebResponse.cs
- UnionExpr.cs
- MatrixCamera.cs
- SafeSystemMetrics.cs
- SecurityHeaderElementInferenceEngine.cs
- SwitchElementsCollection.cs
- FixedSOMImage.cs
- CustomBinding.cs
- SafeReadContext.cs
- StrongNamePublicKeyBlob.cs
- DataGridRowHeaderAutomationPeer.cs
- NullRuntimeConfig.cs
- hresults.cs
- XAMLParseException.cs
- CryptoStream.cs
- EncoderExceptionFallback.cs
- Converter.cs
- MasterPage.cs
- SourceFileBuildProvider.cs
- PassportAuthenticationEventArgs.cs
- BeginStoryboard.cs
- RoutedEventValueSerializer.cs
- XPathSelectionIterator.cs
- InstanceHandleReference.cs
- HwndHost.cs
- CompressionTransform.cs
- ExecutionEngineException.cs
- MobileRedirect.cs
- NegotiationTokenAuthenticatorState.cs
- ConstraintConverter.cs
- IPAddressCollection.cs
- Int64.cs
- BamlResourceContent.cs
- ActivityExecutor.cs
- ImageMap.cs
- WebProxyScriptElement.cs
- StringHandle.cs
- CacheDependency.cs
- wgx_sdk_version.cs
- HandledMouseEvent.cs
- ClientTargetSection.cs
- ImageAttributes.cs
- _Events.cs
- QuaternionRotation3D.cs
- HttpListenerResponse.cs
- OleDbConnectionInternal.cs
- XmlSchemaObjectTable.cs
- RuntimeIdentifierPropertyAttribute.cs
- QilLiteral.cs
- RegexCompiler.cs
- ScriptResourceDefinition.cs
- ExceptionHelpers.cs
- BindingManagerDataErrorEventArgs.cs
- Documentation.cs
- HtmlInputHidden.cs
- ObjectConverter.cs
- LocationSectionRecord.cs
- Identity.cs
- AnnotationStore.cs
- FunctionImportMapping.cs
- TypeCacheManager.cs
- CultureSpecificStringDictionary.cs
- UserControlBuildProvider.cs
- SessionStateContainer.cs
- HScrollProperties.cs
- Method.cs