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
- RevocationPoint.cs
- TextSearch.cs
- CipherData.cs
- TouchEventArgs.cs
- WinFormsUtils.cs
- CategoryState.cs
- ReadOnlyNameValueCollection.cs
- WmlTextViewAdapter.cs
- ButtonStandardAdapter.cs
- ActivityCodeDomSerializer.cs
- CultureInfoConverter.cs
- HandlerFactoryWrapper.cs
- Trigger.cs
- RightsManagementEncryptionTransform.cs
- AxImporter.cs
- TextTreeText.cs
- UrlAuthorizationModule.cs
- FormsAuthenticationUser.cs
- BitmapEffectOutputConnector.cs
- ListDataBindEventArgs.cs
- StatusBar.cs
- NumberFormatter.cs
- ProfileInfo.cs
- Int32Animation.cs
- TableColumn.cs
- FontCollection.cs
- BeginStoryboard.cs
- ClientEndpointLoader.cs
- DataSourceConverter.cs
- MetafileHeaderWmf.cs
- DataGridColumnFloatingHeader.cs
- TextMarkerSource.cs
- StartFileNameEditor.cs
- HyperLinkStyle.cs
- PasswordBox.cs
- ResourceAssociationSet.cs
- PngBitmapDecoder.cs
- Size.cs
- ScriptRef.cs
- Version.cs
- StorageEntitySetMapping.cs
- AnnotationAdorner.cs
- shaper.cs
- ApplicationSecurityManager.cs
- UrlPath.cs
- TempFiles.cs
- NetworkInterface.cs
- CustomTrackingQuery.cs
- ColorTranslator.cs
- WebPartChrome.cs
- JulianCalendar.cs
- PingOptions.cs
- Helpers.cs
- GacUtil.cs
- EditingCoordinator.cs
- ScaleTransform3D.cs
- HighlightComponent.cs
- OleDbSchemaGuid.cs
- XmlProcessingInstruction.cs
- BindableTemplateBuilder.cs
- MobileControlDesigner.cs
- CharacterMetrics.cs
- ApplyImportsAction.cs
- EndpointAddressMessageFilter.cs
- Base64Encoding.cs
- WebScriptServiceHostFactory.cs
- CodeConditionStatement.cs
- SyntaxCheck.cs
- GridEntryCollection.cs
- Accessible.cs
- ScanQueryOperator.cs
- ResponseBodyWriter.cs
- SponsorHelper.cs
- Int16AnimationUsingKeyFrames.cs
- WebServiceFault.cs
- MemoryFailPoint.cs
- AvTrace.cs
- CancellationState.cs
- OneWayChannelListener.cs
- TextTreeObjectNode.cs
- DesignerActionUIStateChangeEventArgs.cs
- _FtpControlStream.cs
- ClientRoleProvider.cs
- CommandExpr.cs
- XmlTextReaderImpl.cs
- GenericPrincipal.cs
- XmlSchemaExporter.cs
- OLEDB_Util.cs
- DefinitionBase.cs
- BinaryFormatter.cs
- ThaiBuddhistCalendar.cs
- NamespaceEmitter.cs
- RangeBaseAutomationPeer.cs
- SByte.cs
- PackageRelationship.cs
- ToolStripContentPanel.cs
- SspiHelper.cs
- AddInToken.cs
- ConstrainedDataObject.cs
- EmptyCollection.cs