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
- ExceptionHandlers.cs
- FixedSOMElement.cs
- TimeSpanMinutesConverter.cs
- DataTable.cs
- WindowsContainer.cs
- MediaElementAutomationPeer.cs
- documentsequencetextcontainer.cs
- StylusPointPropertyId.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- ToolStripItemCollection.cs
- StringPropertyBuilder.cs
- InheritablePropertyChangeInfo.cs
- UndoEngine.cs
- FileChangesMonitor.cs
- DBNull.cs
- ConnectorDragDropGlyph.cs
- HtmlImage.cs
- InkCanvasFeedbackAdorner.cs
- KeyNotFoundException.cs
- XmlDataSource.cs
- SHA256.cs
- TraceHandlerErrorFormatter.cs
- DefaultEventAttribute.cs
- DataGridItemCollection.cs
- HtmlTableCell.cs
- TrustSection.cs
- XmlSchemaNotation.cs
- SimpleFileLog.cs
- SoapSchemaExporter.cs
- BeginEvent.cs
- Int32RectValueSerializer.cs
- ProviderBase.cs
- ThicknessAnimationBase.cs
- DiscoveryMessageSequenceGenerator.cs
- ValidatorCollection.cs
- XmlIterators.cs
- TransportConfigurationTypeElement.cs
- DecoderFallbackWithFailureFlag.cs
- SQLBytes.cs
- ElementFactory.cs
- Descriptor.cs
- OleDbEnumerator.cs
- TableLayoutCellPaintEventArgs.cs
- EventLevel.cs
- WindowsListViewItem.cs
- MasterPageBuildProvider.cs
- ListBoxChrome.cs
- Rule.cs
- EntitySetBase.cs
- TraversalRequest.cs
- OleDbErrorCollection.cs
- XmlDictionaryWriter.cs
- DataGridColumn.cs
- CodeArgumentReferenceExpression.cs
- X509CertificateInitiatorServiceCredential.cs
- ScrollBarRenderer.cs
- DPCustomTypeDescriptor.cs
- ConfigurationValues.cs
- DoubleLink.cs
- BitmapEffect.cs
- ToggleButtonAutomationPeer.cs
- AssociationSetEnd.cs
- ClusterSafeNativeMethods.cs
- ObjectHandle.cs
- SizeChangedInfo.cs
- InvalidPrinterException.cs
- PasswordBox.cs
- RC2.cs
- ServiceDescriptionSerializer.cs
- TraceSource.cs
- TcpTransportSecurity.cs
- PropertyItemInternal.cs
- Size.cs
- ImageConverter.cs
- RequestValidator.cs
- RelatedPropertyManager.cs
- ListBoxItemAutomationPeer.cs
- PostBackTrigger.cs
- XPathEmptyIterator.cs
- BitmapEffect.cs
- TrackBar.cs
- DataGridLinkButton.cs
- ImageSource.cs
- HttpCachePolicyElement.cs
- SQLInt64.cs
- SchemaInfo.cs
- UnlockInstanceAsyncResult.cs
- InputScopeManager.cs
- InkCanvasSelection.cs
- VisualStyleTypesAndProperties.cs
- DataSpaceManager.cs
- SHA1.cs
- HttpRawResponse.cs
- DependencyObjectValidator.cs
- OleDbDataAdapter.cs
- CollectionChangeEventArgs.cs
- SecurityKeyUsage.cs
- StorageModelBuildProvider.cs
- MouseEvent.cs
- SmtpCommands.cs