Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- TypedReference.cs
- PTUtility.cs
- PointCollection.cs
- FileDialogCustomPlacesCollection.cs
- Rotation3DKeyFrameCollection.cs
- uribuilder.cs
- WorkflowPersistenceContext.cs
- wgx_render.cs
- DrawingAttributesDefaultValueFactory.cs
- StsCommunicationException.cs
- Properties.cs
- WinEventTracker.cs
- TextFormatterHost.cs
- ProxyFragment.cs
- GrammarBuilderRuleRef.cs
- ISCIIEncoding.cs
- UpnEndpointIdentityExtension.cs
- DoubleCollection.cs
- LineUtil.cs
- XmlSchemaElement.cs
- SectionRecord.cs
- HitTestWithGeometryDrawingContextWalker.cs
- ToolZone.cs
- MenuItem.cs
- XmlAttributeCache.cs
- HttpFileCollection.cs
- WebPartHelpVerb.cs
- WindowsFormsHelpers.cs
- DropDownHolder.cs
- SerializationEventsCache.cs
- RightNameExpirationInfoPair.cs
- DataGridClipboardCellContent.cs
- BufferedReadStream.cs
- ObjectDataSourceDisposingEventArgs.cs
- EditorOptionAttribute.cs
- QuinticEase.cs
- CodeArrayCreateExpression.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- NameValuePair.cs
- ObjectItemCollection.cs
- Clipboard.cs
- DataBindingsDialog.cs
- ListViewSelectEventArgs.cs
- Dump.cs
- GatewayDefinition.cs
- EmbeddedObject.cs
- UrlPropertyAttribute.cs
- userdatakeys.cs
- FunctionNode.cs
- ExpressionCopier.cs
- FrameworkTemplate.cs
- SystemColors.cs
- TableLayout.cs
- PhonemeConverter.cs
- DocumentViewerHelper.cs
- FixedDSBuilder.cs
- WizardSideBarListControlItem.cs
- KeyNotFoundException.cs
- BooleanStorage.cs
- ListGeneralPage.cs
- MobileResource.cs
- StrokeNodeOperations.cs
- ValidatingPropertiesEventArgs.cs
- DataFormats.cs
- DefaultValidator.cs
- ModelServiceImpl.cs
- CodeAssignStatement.cs
- MouseActionConverter.cs
- StrokeFIndices.cs
- AuthorizationSection.cs
- EncryptedPackageFilter.cs
- SqlProfileProvider.cs
- ConfigurationPropertyCollection.cs
- RangeBase.cs
- SharedPerformanceCounter.cs
- BitmapDecoder.cs
- ExceptionHelpers.cs
- SystemWebSectionGroup.cs
- CheckPair.cs
- Page.cs
- ProfileParameter.cs
- HelpInfo.cs
- TreeViewHitTestInfo.cs
- AppSecurityManager.cs
- SqlConnectionString.cs
- ApplicationDirectoryMembershipCondition.cs
- MSG.cs
- AuthorizationRuleCollection.cs
- HashRepartitionStream.cs
- Assert.cs
- TerminateSequence.cs
- AuthenticationManager.cs
- DataSourceHelper.cs
- DomainLiteralReader.cs
- XmlName.cs
- SqlClientFactory.cs
- PeerNameRecordCollection.cs
- SpecularMaterial.cs
- TextPatternIdentifiers.cs
- PropertyIDSet.cs