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
- WebPartConnectionsDisconnectVerb.cs
- SHA512.cs
- NativeActivityContext.cs
- RequestQueue.cs
- SortDescriptionCollection.cs
- ListViewGroup.cs
- KeyValueConfigurationElement.cs
- SimpleLine.cs
- XamlVector3DCollectionSerializer.cs
- ValidatedControlConverter.cs
- TextDocumentView.cs
- DesignerValidatorAdapter.cs
- NetTcpSecurity.cs
- ListViewCommandEventArgs.cs
- Converter.cs
- EFDataModelProvider.cs
- PageStatePersister.cs
- ClonableStack.cs
- ButtonChrome.cs
- configsystem.cs
- AsmxEndpointPickerExtension.cs
- LogSwitch.cs
- Mouse.cs
- TableMethodGenerator.cs
- Frame.cs
- mediapermission.cs
- RangeValidator.cs
- HandlerMappingMemo.cs
- PathFigure.cs
- DispatcherTimer.cs
- SerializationStore.cs
- XmlDsigSep2000.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- CodeDOMProvider.cs
- EditingCommands.cs
- ViewRendering.cs
- DelegateTypeInfo.cs
- assertwrapper.cs
- XPathSingletonIterator.cs
- DynamicMethod.cs
- Enum.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- ResourceProviderFactory.cs
- WebPartConnectionsCancelEventArgs.cs
- log.cs
- PersistenceProvider.cs
- EventlogProvider.cs
- _Events.cs
- Roles.cs
- CacheForPrimitiveTypes.cs
- HybridObjectCache.cs
- PrimitiveXmlSerializers.cs
- ToolStripLocationCancelEventArgs.cs
- ErrorHandler.cs
- XmlSchemaInclude.cs
- JobPageOrder.cs
- BamlCollectionHolder.cs
- _IPv6Address.cs
- SynchronizationValidator.cs
- WrappedIUnknown.cs
- SoapCodeExporter.cs
- MatrixConverter.cs
- OrderByQueryOptionExpression.cs
- DesignerTransactionCloseEvent.cs
- NullableDoubleSumAggregationOperator.cs
- WebUtil.cs
- PrintingPermissionAttribute.cs
- ExpandoObject.cs
- TaiwanCalendar.cs
- Module.cs
- ScaleTransform3D.cs
- TextTreePropertyUndoUnit.cs
- DbProviderFactoriesConfigurationHandler.cs
- AutoGeneratedFieldProperties.cs
- MessagePropertyDescription.cs
- StorageRoot.cs
- DictionaryMarkupSerializer.cs
- WSDualHttpSecurityMode.cs
- RepeatButtonAutomationPeer.cs
- IPEndPoint.cs
- TraceXPathNavigator.cs
- StringInfo.cs
- EnumerableRowCollectionExtensions.cs
- PageClientProxyGenerator.cs
- FileDialog.cs
- OrderedHashRepartitionEnumerator.cs
- RoutedUICommand.cs
- TokenDescriptor.cs
- DataGridViewCellStyleChangedEventArgs.cs
- TextEndOfParagraph.cs
- RequestCache.cs
- ListViewItem.cs
- MustUnderstandSoapException.cs
- CachedFontFace.cs
- PropertyInfoSet.cs
- TimeSpanConverter.cs
- MailDefinition.cs
- DurableTimerExtension.cs
- Vector3dCollection.cs
- InputLangChangeRequestEvent.cs