- 3Dave
40个虚拟目录?那么你有40个不同的应用程序。嗯,这似乎很多。你正在开发什么样的网站?我知道一些小型托管提供商在其服务器上的虚拟目录比你少 :-) - Darin Dimitrov
不,这不是40个不同的应用程序。我正在逐步将一个巨大的(400k+代码行和超过100,000页)经典ASP应用程序迁移到.NET MVC。虚拟文件夹使新站点可以访问旧网址上的旧内容。 - 3Dave
3个回答
public void CreateVirtualDirectory() { DirectoryEntry oDE = new DirectoryEntry("IIS://" + this._strServerName + "/W3SVC/" + _webSiteID + "/Root"); //Get Default Web Site DirectoryEntries oDC = oDE.Children; //Add row to schema DirectoryEntry oVirDir = oDC.Add(this._strVDirName, oDE.SchemaClassName.ToString()); //Commit changes for Schema class File oVirDir.CommitChanges(); //Set virtual directory to physical path oVirDir.Properties["Path"].Value = this._strPhysicalPath; //Set read access oVirDir.Properties["AccessRead"][0] = true; //Set the default docs oVirDir.Properties["EnableDefaultDoc"][0] = true; oVirDir.Properties["DefaultDoc"][0] = "default.aspx"; //set the name oVirDir.Properties["AppFriendlyName"][0] = this._strVDirName; //do it oVirDir.Invoke("AppCreate", true); //set the application pool if (!string.IsNullOrEmpty(_strApplicationPool)) { object[] param = { 0, _strApplicationPool, true }; oVirDir.Invoke("AppCreate3", param); oVirDir.Properties["AppIsolated"][0] = "2"; } //Save all the changes oVirDir.CommitChanges(); }
- AaronS
感谢提供代码示例。当然,我希望能够得到更自动化的东西,但这肯定可以完成任务。 - 3Dave
我还没有使用WebDeploy进行任何定制编程,但我看到有提到它有一个API。我似乎找不到官方文档,但也许这篇博客和示例应用程序可以提供一个起点:Web Deploy API Web Application
- moribvndvs
请问您能分享一下您的解决方案吗?我正在使用WebDeploy将一个asp.net webforms应用程序部署到IIS,我需要创建02个虚拟目录(指向不同的驱动器),用于存放.pdf文件。
我该如何在我的.pubxml文件中挂钩AaronS提到的CustomBuildTask?以下是文件的片段。
<?xml version="1.0" encoding="utf-8"?> <!-- This file is used by the publish/package process of your Web project. You can customize the behavior of this process by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <WebPublishMethod>MSDeploy</WebPublishMethod> <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedPlatform>Any CPU</LastUsedPlatform> <SiteUrlToLaunchAfterPublish>https://www.myapplication.com/app</SiteUrlToLaunchAfterPublish> <ExcludeApp_Data>False</ExcludeApp_Data> <MSDeployServiceURL>www.myapplication.com</MSDeployServiceURL> <DeployIisAppPath>Default Web Site/app</DeployIisAppPath> <RemoteSitePhysicalPath /> <SkipExtraFilesOnServer>False</SkipExtraFilesOnServer> <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod> <EnableMSDeployBackup>True</EnableMSDeployBackup> <UserName>administrator</UserName> <_SavePWD>True</_SavePWD> <PublishDatabaseSettings> <!-- ... --> </PublishDatabaseSettings> <PrecompileBeforePublish>True</PrecompileBeforePublish> <EnableUpdateable>True</EnableUpdateable> <DebugSymbols>False</DebugSymbols> <WDPMergeOption>DonotMerge</WDPMergeOption> </PropertyGroup> <ItemGroup> <MSDeployParameterValue Include="$(DeployParameterPrefix)SiteConnectionString-Web.config Connection String" /> </ItemGroup> </Project>
当我从Visual Studio 2019发布应用程序后,IIS应该有pdfmedia虚拟目录。
非常感谢!本文链接:https://www.kinber.cn/post/4682.html 转载需授权!
推荐本站淘宝优惠价购买喜欢的宝贝: