Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Hosting / SimpleApplicationHost.cs / 2 / 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);
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeDOMProvider.cs
- WebPartVerbCollection.cs
- LinqDataSourceDisposeEventArgs.cs
- SID.cs
- MemberRelationshipService.cs
- ListViewCommandEventArgs.cs
- LazyTextWriterCreator.cs
- SwitchElementsCollection.cs
- ManualResetEventSlim.cs
- SimpleWebHandlerParser.cs
- COM2Properties.cs
- StringArrayConverter.cs
- IMembershipProvider.cs
- SynchronizedDispatch.cs
- DBPropSet.cs
- ColorIndependentAnimationStorage.cs
- MetabaseServerConfig.cs
- CacheDict.cs
- RawAppCommandInputReport.cs
- DebugController.cs
- FixedSOMFixedBlock.cs
- X509UI.cs
- AdCreatedEventArgs.cs
- GridViewColumnCollection.cs
- SystemSounds.cs
- UserControlBuildProvider.cs
- WpfPayload.cs
- EventWaitHandleSecurity.cs
- TimelineClockCollection.cs
- UnsafeCollabNativeMethods.cs
- WorkflowItemsPresenter.cs
- KeyBinding.cs
- TextTreeTextNode.cs
- ItemDragEvent.cs
- LassoHelper.cs
- StatusBarDrawItemEvent.cs
- ServicePrincipalNameElement.cs
- AccessDataSourceView.cs
- WebServiceParameterData.cs
- SystemEvents.cs
- HtmlSelect.cs
- MarginsConverter.cs
- EmbeddedObject.cs
- StrokeFIndices.cs
- FormatConvertedBitmap.cs
- SHA384.cs
- GeneralTransformGroup.cs
- RelationshipConstraintValidator.cs
- TableLayoutStyle.cs
- ArgumentNullException.cs
- LambdaCompiler.Binary.cs
- TreeNodeBinding.cs
- CalendarDay.cs
- MetadataProperty.cs
- GrammarBuilderPhrase.cs
- EmptyCollection.cs
- SchemaSetCompiler.cs
- BackoffTimeoutHelper.cs
- InputProcessorProfiles.cs
- NameValueConfigurationElement.cs
- WindowsFormsSynchronizationContext.cs
- FileVersion.cs
- CustomValidator.cs
- DNS.cs
- QueryHandler.cs
- OutputCacheEntry.cs
- DragAssistanceManager.cs
- SchemaLookupTable.cs
- GorillaCodec.cs
- SerializationSectionGroup.cs
- HtmlInputText.cs
- DataControlField.cs
- Token.cs
- MachineKeyValidationConverter.cs
- ProfileModule.cs
- AnnotationDocumentPaginator.cs
- SignatureTargetIdManager.cs
- EntitySqlQueryCacheEntry.cs
- Publisher.cs
- FontStyle.cs
- DataGridViewComboBoxColumn.cs
- OutOfMemoryException.cs
- BindingExpressionUncommonField.cs
- ProfileInfo.cs
- FieldBuilder.cs
- SamlAuthenticationStatement.cs
- XsltQilFactory.cs
- StorageEntityContainerMapping.cs
- ItemCheckEvent.cs
- ReadOnlyCollection.cs
- FrameworkContentElementAutomationPeer.cs
- HelpInfo.cs
- Matrix.cs
- AutoResetEvent.cs
- CustomErrorCollection.cs
- Quaternion.cs
- SetMemberBinder.cs
- BamlRecordHelper.cs
- Enum.cs
- SecurityException.cs