Ms.Web.Adminを介したIIS7でのWebアプリケーションの作成
-
26-09-2019 - |
質問
Microsoft.Web.Administration DLLを使用して、IIS7のアプリケーションとして、個別のワークフローインスタンスを作成しようとしています。サイトアプリケーションコレクションにアプリケーションを追加しようとすると、comエラーが表示されます。「無効なアプリケーションパス r n」
using (ServerManager manager = new ServerManager())
{
var site = manager.Sites.Where(x => x.Name == Properties.Settings.Default.WorkflowWebsiteName).Single();
StringBuilder stringBuilder = new StringBuilder()
.Append(m_workflowDefinition.AccountId)
.Append("/")
.Append(m_workflowDefinition.WorkflowDefinitionId)
.Append("/")
.Append(m_workflowDefinition.Version)
.Append("/");
string virtualPath = stringBuilder.ToString();
string physicalPath = Properties.Settings.Default.ApplicationPoolString +
virtualPath.Replace("/", "\\");
if (!Directory.Exists(physicalPath)) Directory.CreateDirectory(physicalPath);
//Create the workflow service definition file
using (StreamWriter writer = new StreamWriter(Path.Combine(physicalPath, m_workflowDefinition.WorkflowName + WORKFLOW_FILE_EXTENSION)))
{
writer.Write(m_workflowDefinition.Definition);
}
//Copy dependencies
string dependencyPath = m_workflowDefinition.DependenciesPath;
CopyAll(new DirectoryInfo(dependencyPath), new DirectoryInfo(physicalPath));
//Create a new IIS application for the workflow
var apps = site.Applications.Where(x => x.Path == virtualPath);
if (apps.Count() > 0)
{
site.Applications.Remove(apps.Single());
}
Application app = site.Applications.Add(virtualPath, physicalPath);
app.ApplicationPoolName = "Workflow AppPool";
app.EnabledProtocols = PROTOCOLS;
manager.CommitChanges();
}
VirtualPathに割り当てられた値は、「何か/何か/何か」のようなものであり、物理的なパスの場合は「C: inetPub wwwroot workflow something something something」です。何か案は?
どんな助けも大歓迎です。
解決
「/何か/何か/何か」への「何か/何か/何か」パスを変更してみてください。 IIS管理コールには、パスの先頭に追加のスラッシュが必要です。
所属していません StackOverflow