本文整理汇总了C#中IApplicationHost.GetConfigMapPathFactory方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationHost.GetConfigMapPathFactory方法的具体用法?C# IApplicationHost.GetConfigMapPathFactory怎么用?C# IApplicationHost.GetConfigMapPathFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationHost
的用法示例。
在下文中一共展示了IApplicationHost.GetConfigMapPathFactory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAppDomainWithHostingEnvironment
private HostingEnvironment CreateAppDomainWithHostingEnvironment(string appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
{
string physicalPath = appHost.GetPhysicalPath();
if (!System.Web.Util.StringUtil.StringEndsWith(physicalPath, Path.DirectorySeparatorChar))
{
physicalPath = physicalPath + Path.DirectorySeparatorChar;
}
string domainId = ConstructAppDomainId(appId);
string appName = System.Web.Util.StringUtil.GetStringHashCode(appId.ToLower(CultureInfo.InvariantCulture) + physicalPath.ToLower(CultureInfo.InvariantCulture)).ToString("x", CultureInfo.InvariantCulture);
VirtualPath appVPath = VirtualPath.Create(appHost.GetVirtualPath());
IDictionary dict = new Hashtable(20);
AppDomainSetup setup = new AppDomainSetup();
PopulateDomainBindings(domainId, appId, appName, physicalPath, appVPath, setup, dict);
AppDomain domain = null;
Exception innerException = null;
string siteID = appHost.GetSiteID();
string virtualPathStringNoTrailingSlash = appVPath.VirtualPathStringNoTrailingSlash;
bool flag = false;
bool flag2 = false;
System.Configuration.Configuration configuration = null;
PolicyLevel policyLevel = null;
PermissionSet grantSet = null;
List<StrongName> list = new List<StrongName>();
string[] strArray = new string[] { "System.Web, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293", "System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.Abstractions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.Routing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.ComponentModel.DataAnnotations, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.DynamicData, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.DataVisualization, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9", "System.Web.ApplicationServices, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9" };
Exception appDomainCreationException = null;
ImpersonationContext context = null;
IntPtr zero = IntPtr.Zero;
if ((hostingParameters != null) && ((hostingParameters.HostingFlags & HostingEnvironmentFlags.ClientBuildManager) != HostingEnvironmentFlags.Default))
{
flag2 = true;
setup.LoaderOptimization = LoaderOptimization.MultiDomainHost;
}
try
{
zero = appHost.GetConfigToken();
if (zero != IntPtr.Zero)
{
context = new ImpersonationContext(zero);
}
try
{
if (flag2 && (hostingParameters.IISExpressVersion != null))
{
grantSet = new PermissionSet(PermissionState.Unrestricted);
setup.PartialTrustVisibleAssemblies = strArray;
}
else
{
if (appHost is ISAPIApplicationHost)
{
string key = "f" + siteID + appVPath.VirtualPathString;
MapPathCacheInfo info1 = (MapPathCacheInfo) HttpRuntime.CacheInternal.Remove(key);
configuration = WebConfigurationManager.OpenWebConfiguration(virtualPathStringNoTrailingSlash, siteID);
}
else
{
WebConfigurationFileMap fileMap = new WebConfigurationFileMap();
IConfigMapPath path2 = appHost.GetConfigMapPathFactory().Create(appVPath.VirtualPathString, physicalPath);
string directory = null;
string baseName = null;
string path = "/";
path2.GetPathConfigFilename(siteID, path, out directory, out baseName);
if (directory != null)
{
fileMap.VirtualDirectories.Add(path, new VirtualDirectoryMapping(Path.GetFullPath(directory), true));
}
foreach (string str10 in virtualPathStringNoTrailingSlash.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries))
{
path = path + str10;
path2.GetPathConfigFilename(siteID, path, out directory, out baseName);
if (directory != null)
{
fileMap.VirtualDirectories.Add(path, new VirtualDirectoryMapping(Path.GetFullPath(directory), true));
}
path = path + "/";
}
configuration = WebConfigurationManager.OpenMappedWebConfiguration(fileMap, virtualPathStringNoTrailingSlash, siteID);
}
TrustSection trustSection = (TrustSection) configuration.GetSection("system.web/trust");
if ((trustSection == null) || string.IsNullOrEmpty(trustSection.Level))
{
throw new ConfigurationErrorsException(System.Web.SR.GetString("Config_section_not_present", new object[] { "trust" }));
}
bool legacyCasModel = trustSection.LegacyCasModel;
if (legacyCasModel)
{
SetNetFx40LegacySecurityPolicy(setup);
}
if (flag2)
{
grantSet = new PermissionSet(PermissionState.Unrestricted);
setup.PartialTrustVisibleAssemblies = strArray;
}
else
{
flag = legacyCasModel;
if (!flag)
{
if (trustSection.Level == "Full")
{
//.........这里部分代码省略.........