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
- SettingsBase.cs
- FloatSumAggregationOperator.cs
- SHA256Managed.cs
- RewritingProcessor.cs
- CatalogZone.cs
- EqualityComparer.cs
- DataGridCellInfo.cs
- processwaithandle.cs
- ToolStripSplitButton.cs
- CodeAccessSecurityEngine.cs
- ModuleElement.cs
- ReadOnlyCollectionBase.cs
- VerificationAttribute.cs
- BufferedReadStream.cs
- XmlTextEncoder.cs
- XamlTreeBuilder.cs
- OdbcException.cs
- UnsafeNativeMethods.cs
- TTSEvent.cs
- CodeNamespace.cs
- UrlPropertyAttribute.cs
- SmtpFailedRecipientException.cs
- PropertyManager.cs
- MbpInfo.cs
- SerializationEventsCache.cs
- ExecutedRoutedEventArgs.cs
- Listbox.cs
- ZipIOModeEnforcingStream.cs
- ListBindableAttribute.cs
- CreateUserWizard.cs
- COM2PictureConverter.cs
- StylusPlugin.cs
- QilParameter.cs
- TextModifierScope.cs
- _CommandStream.cs
- WindowsPrincipal.cs
- IDQuery.cs
- HttpRequestCacheValidator.cs
- DuplexChannelFactory.cs
- DefaultHttpHandler.cs
- Renderer.cs
- RowToParametersTransformer.cs
- XmlSiteMapProvider.cs
- RegistryDataKey.cs
- NaturalLanguageHyphenator.cs
- QueryStatement.cs
- SecurityKeyType.cs
- UrlMappingsModule.cs
- IgnorePropertiesAttribute.cs
- GridItemPattern.cs
- TableRowsCollectionEditor.cs
- ClientRolePrincipal.cs
- FixedFlowMap.cs
- ProxyWebPartConnectionCollection.cs
- WebControlAdapter.cs
- ExpressionReplacer.cs
- SingleConverter.cs
- FunctionMappingTranslator.cs
- AsymmetricKeyExchangeFormatter.cs
- NamespaceList.cs
- StatusBarDrawItemEvent.cs
- GeometryDrawing.cs
- DataContractSet.cs
- StructuralObject.cs
- FormatControl.cs
- FontDialog.cs
- DBDataPermissionAttribute.cs
- _NegoStream.cs
- UInt64Converter.cs
- _NetworkingPerfCounters.cs
- SystemPens.cs
- StringArrayConverter.cs
- EventDescriptor.cs
- EntityDataSourceDataSelection.cs
- PerspectiveCamera.cs
- Base64Stream.cs
- XmlSchemaComplexContentRestriction.cs
- BulletChrome.cs
- ResourceSet.cs
- _SslSessionsCache.cs
- BrowserCapabilitiesCodeGenerator.cs
- ConfigurationStrings.cs
- SortedDictionary.cs
- MultipartContentParser.cs
- WebMessageEncoderFactory.cs
- BindingSourceDesigner.cs
- IdentityModelStringsVersion1.cs
- DefaultShape.cs
- StringCollection.cs
- HelloMessage11.cs
- OrderedDictionaryStateHelper.cs
- XmlSchemaDatatype.cs
- MessagePartDescription.cs
- SQLBoolean.cs
- OpenCollectionAsyncResult.cs
- WebScriptServiceHost.cs
- KeyConverter.cs
- MetricEntry.cs
- As.cs
- SiteIdentityPermission.cs