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
- MenuItemStyleCollection.cs
- Typeface.cs
- GenericsInstances.cs
- WindowsIdentity.cs
- XmlElementList.cs
- DefaultParameterValueAttribute.cs
- ConsumerConnectionPoint.cs
- XmlSchemaAll.cs
- String.cs
- FontFamily.cs
- SerialReceived.cs
- ImageMapEventArgs.cs
- HandlerBase.cs
- FutureFactory.cs
- RenderContext.cs
- XmlIgnoreAttribute.cs
- BuildResult.cs
- SizeChangedEventArgs.cs
- DropDownList.cs
- ChannelDemuxer.cs
- Page.cs
- DataGridColumnFloatingHeader.cs
- Util.cs
- TemplateField.cs
- DSACryptoServiceProvider.cs
- ImageAnimator.cs
- XmlAnyElementAttribute.cs
- TypeResolver.cs
- ContentElementCollection.cs
- BaseProcessor.cs
- HashAlgorithm.cs
- FormatSettings.cs
- BooleanStorage.cs
- RadioButton.cs
- SoapIncludeAttribute.cs
- SizeAnimationUsingKeyFrames.cs
- TimelineClockCollection.cs
- CustomValidator.cs
- GreaterThan.cs
- EventItfInfo.cs
- FontInfo.cs
- ActivityDesigner.cs
- DataGridViewComboBoxEditingControl.cs
- NestPullup.cs
- PauseStoryboard.cs
- ColumnCollection.cs
- QueryGenerator.cs
- XmlRawWriter.cs
- IdnMapping.cs
- Stylesheet.cs
- ValueConversionAttribute.cs
- ToolStripDropDownItemDesigner.cs
- WebPartEditorOkVerb.cs
- CodeTypeMember.cs
- ConfigurationProperty.cs
- ArgIterator.cs
- figurelength.cs
- TileModeValidation.cs
- ResolveMatchesApril2005.cs
- Ticks.cs
- WebContext.cs
- BamlCollectionHolder.cs
- TextBoxBase.cs
- AuthorizationSection.cs
- Timer.cs
- RangeEnumerable.cs
- IdentityReference.cs
- StylusButtonCollection.cs
- altserialization.cs
- DocumentSequence.cs
- ImageSourceConverter.cs
- LightweightCodeGenerator.cs
- AppliedDeviceFiltersEditor.cs
- AutomationPattern.cs
- XmlReflectionMember.cs
- XmlText.cs
- ViewUtilities.cs
- Int32CollectionConverter.cs
- PackageRelationshipCollection.cs
- XmlILTrace.cs
- CheckPair.cs
- DesignerToolStripControlHost.cs
- MsmqProcessProtocolHandler.cs
- PackagingUtilities.cs
- SvcMapFileLoader.cs
- FullTrustAssemblyCollection.cs
- ListViewCommandEventArgs.cs
- RefreshPropertiesAttribute.cs
- RegexMatchCollection.cs
- MetadataPropertyAttribute.cs
- NavigationProgressEventArgs.cs
- MailAddress.cs
- MouseBinding.cs
- EventPrivateKey.cs
- ConfigXmlWhitespace.cs
- XmlTextReader.cs
- SelectionItemPattern.cs
- SimpleTypeResolver.cs
- MarkerProperties.cs
- HierarchicalDataSourceDesigner.cs