Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Hosting / SimpleApplicationHost.cs / 3 / 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 ( 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. //------------------------------------------------------------------------------ //// 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 ( 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TabPanel.cs
- ListViewHitTestInfo.cs
- AutoGeneratedField.cs
- InstalledVoice.cs
- ThreadStaticAttribute.cs
- EventlogProvider.cs
- BodyWriter.cs
- MessageSecurityOverMsmq.cs
- NegatedCellConstant.cs
- CatalogPartDesigner.cs
- XPathParser.cs
- DayRenderEvent.cs
- DataGridViewAdvancedBorderStyle.cs
- ViewCellSlot.cs
- GridViewRow.cs
- LineUtil.cs
- SimpleRecyclingCache.cs
- FamilyMap.cs
- WindowsAltTab.cs
- FontSizeConverter.cs
- JoinSymbol.cs
- HierarchicalDataSourceControl.cs
- SymbolMethod.cs
- EntityCodeGenerator.cs
- OdbcStatementHandle.cs
- MappedMetaModel.cs
- TransportOutputChannel.cs
- MachineKeyConverter.cs
- TripleDES.cs
- WebPartUserCapability.cs
- DBSchemaTable.cs
- __Filters.cs
- RotateTransform.cs
- ExpressionVisitor.cs
- ClientSection.cs
- ModelUIElement3D.cs
- Axis.cs
- IgnoreFlushAndCloseStream.cs
- RetriableClipboard.cs
- WindowInteropHelper.cs
- RegexRunner.cs
- PersonalizationState.cs
- ServiceBusyException.cs
- RedirectionProxy.cs
- IndexExpression.cs
- FileDialog.cs
- XmlWrappingReader.cs
- ReadOnlyCollection.cs
- SubMenuStyleCollection.cs
- SslStream.cs
- DrawingCollection.cs
- TopClause.cs
- ClientRoleProvider.cs
- WindowsAuthenticationEventArgs.cs
- MarshalDirectiveException.cs
- MultipleViewPattern.cs
- HTMLTagNameToTypeMapper.cs
- Assert.cs
- ButtonBaseAutomationPeer.cs
- RtfToken.cs
- SafePointer.cs
- EntityContainerEntitySet.cs
- TreePrinter.cs
- Span.cs
- DefaultEventAttribute.cs
- HttpStreamXmlDictionaryWriter.cs
- AuthenticatingEventArgs.cs
- JournalEntryListConverter.cs
- XmlNamespaceMappingCollection.cs
- cryptoapiTransform.cs
- DbLambda.cs
- ExtensionQuery.cs
- ConnectionsZone.cs
- VSWCFServiceContractGenerator.cs
- CodeAttachEventStatement.cs
- DES.cs
- RijndaelManaged.cs
- SessionStateContainer.cs
- DeclarativeCatalogPart.cs
- Bezier.cs
- WebPartZoneBaseDesigner.cs
- WebProxyScriptElement.cs
- CodeSnippetExpression.cs
- XmlUtil.cs
- Graph.cs
- ItemContainerPattern.cs
- XmlSchemaSimpleTypeList.cs
- SecurityMessageProperty.cs
- SatelliteContractVersionAttribute.cs
- SqlCommand.cs
- StreamWriter.cs
- SystemBrushes.cs
- Span.cs
- ContentTextAutomationPeer.cs
- DependencyPropertyAttribute.cs
- CheckBoxField.cs
- StylusTip.cs
- XPathBinder.cs
- Vector3D.cs
- Number.cs