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
- TextModifier.cs
- TypeConverter.cs
- SchemaAttDef.cs
- SocketAddress.cs
- GeneralTransform3D.cs
- SelfIssuedAuthRSACryptoProvider.cs
- LogicalExpr.cs
- Size3D.cs
- QilNode.cs
- Int32KeyFrameCollection.cs
- ProcessHostConfigUtils.cs
- RequestQueryProcessor.cs
- SamlSerializer.cs
- EdmMember.cs
- PageBreakRecord.cs
- XhtmlTextWriter.cs
- TextMetrics.cs
- RouteCollection.cs
- SystemSounds.cs
- EnvelopedPkcs7.cs
- DataServiceClientException.cs
- ExternalDataExchangeService.cs
- HandlerMappingMemo.cs
- ExtendedPropertyDescriptor.cs
- DisposableCollectionWrapper.cs
- DataDocumentXPathNavigator.cs
- BuildProviderAppliesToAttribute.cs
- ISFTagAndGuidCache.cs
- MultiBinding.cs
- ServerValidateEventArgs.cs
- MessageLogTraceRecord.cs
- AssemblyName.cs
- SelectionRangeConverter.cs
- UserControlCodeDomTreeGenerator.cs
- ISFClipboardData.cs
- WpfGeneratedKnownProperties.cs
- BufferedGraphics.cs
- ItemMap.cs
- PrintPreviewGraphics.cs
- WebPartDisplayModeCollection.cs
- PageContentCollection.cs
- FileDialogPermission.cs
- Geometry.cs
- CacheEntry.cs
- SapiRecoInterop.cs
- BrowserCapabilitiesCompiler.cs
- BaseCollection.cs
- ZipIOLocalFileBlock.cs
- TablePattern.cs
- ParameterInfo.cs
- Sorting.cs
- CustomError.cs
- IsolationInterop.cs
- NavigationService.cs
- UriWriter.cs
- XmlDocumentType.cs
- DynamicScriptObject.cs
- AccessKeyManager.cs
- CultureNotFoundException.cs
- cryptoapiTransform.cs
- BaseUriHelper.cs
- Not.cs
- GeneralTransform.cs
- AuthorizationSection.cs
- MetadataArtifactLoaderResource.cs
- BooleanAnimationUsingKeyFrames.cs
- Journaling.cs
- BindingManagerDataErrorEventArgs.cs
- AmbientLight.cs
- TextRunCacheImp.cs
- ResolveCriteriaApril2005.cs
- RegisteredExpandoAttribute.cs
- DynamicMethod.cs
- ContainerTracking.cs
- EncoderFallback.cs
- MergeFilterQuery.cs
- HeaderUtility.cs
- StructuredTypeEmitter.cs
- PageFunction.cs
- SQLDateTimeStorage.cs
- MediaElementAutomationPeer.cs
- BamlResourceDeserializer.cs
- PageParserFilter.cs
- CatchBlock.cs
- LogicalExpr.cs
- sitestring.cs
- CancellationHandler.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- ProjectionQueryOptionExpression.cs
- InteropExecutor.cs
- ValidatorCollection.cs
- SmtpNetworkElement.cs
- SRef.cs
- FixedTextBuilder.cs
- Interlocked.cs
- UnsafeNativeMethodsTablet.cs
- Soap.cs
- FixedDSBuilder.cs
- XsdDuration.cs
- DataServiceStreamResponse.cs