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
- ViewLoader.cs
- UIElement3D.cs
- StringConcat.cs
- RequestCacheEntry.cs
- BasePattern.cs
- Helpers.cs
- OuterGlowBitmapEffect.cs
- TrackingProfile.cs
- VirtualPathProvider.cs
- ServiceControllerDesigner.cs
- TrackBarRenderer.cs
- XmlSchemaAttribute.cs
- FormViewPagerRow.cs
- SignedPkcs7.cs
- MethodToken.cs
- Type.cs
- TableCell.cs
- DesignerWidgets.cs
- SoapAttributes.cs
- OleAutBinder.cs
- EventLogPermissionAttribute.cs
- X509PeerCertificateAuthentication.cs
- IRCollection.cs
- StandardOleMarshalObject.cs
- DoubleLinkListEnumerator.cs
- ClientSettings.cs
- ZipFileInfoCollection.cs
- GetMemberBinder.cs
- Converter.cs
- SettingsPropertyValue.cs
- SectionUpdates.cs
- ErrorProvider.cs
- SafeCertificateContext.cs
- CellQuery.cs
- RepeatButtonAutomationPeer.cs
- ContentType.cs
- SafeSerializationManager.cs
- TokenizerHelper.cs
- DataRowChangeEvent.cs
- PreservationFileReader.cs
- EDesignUtil.cs
- ListViewDataItem.cs
- securitycriticaldata.cs
- PrintDocument.cs
- PopOutPanel.cs
- dbenumerator.cs
- StringDictionaryWithComparer.cs
- EndPoint.cs
- DataGridViewCellValueEventArgs.cs
- XslCompiledTransform.cs
- Quaternion.cs
- Int64Converter.cs
- Span.cs
- TextSelectionHighlightLayer.cs
- SafeFindHandle.cs
- DownloadProgressEventArgs.cs
- FormsAuthenticationConfiguration.cs
- PolygonHotSpot.cs
- ResXResourceReader.cs
- DataGridItem.cs
- ZipIOCentralDirectoryFileHeader.cs
- dbenumerator.cs
- Quaternion.cs
- CriticalFinalizerObject.cs
- SessionStateContainer.cs
- WizardStepBase.cs
- Selection.cs
- ResXResourceWriter.cs
- ReadOnlyDictionary.cs
- SoundPlayer.cs
- ConfigXmlCDataSection.cs
- ReachObjectContext.cs
- DependencyObject.cs
- CollectionViewGroupInternal.cs
- DrawingContextWalker.cs
- ControlDesigner.cs
- DrawingBrush.cs
- ListViewInsertionMark.cs
- ApplicationInfo.cs
- PropertyPathWorker.cs
- Operator.cs
- SpeechSynthesizer.cs
- MobileComponentEditorPage.cs
- ProjectionPlanCompiler.cs
- Path.cs
- SubstitutionResponseElement.cs
- GraphicsState.cs
- BindingsCollection.cs
- Internal.cs
- ColorConverter.cs
- Light.cs
- MatrixAnimationUsingPath.cs
- DesignerTransactionCloseEvent.cs
- ConfigurationFileMap.cs
- GenerateTemporaryTargetAssembly.cs
- PeerNameRecordCollection.cs
- NamespaceQuery.cs
- SQLMoneyStorage.cs
- FileSystemInfo.cs
- WebPartTracker.cs