一个应用服务中是否可以有 2 个 ASP.NET Core Web API 应用?
我知道最好将这 2 个站点放在单独的应用服务中,但我们的用例有点独特。
我们尝试添加第二个站点,以便使用 applicationInitialization 功能在应用程序启动和向应用程序服务负载均衡器提供实例之间引入延迟。 我可以对此进行更详细的介绍,但我现在想要的是附加一个额外的网站,applicationInitialization 可以调用该网站来延迟启动过程。
我已经尝试过:
Folder structure:
/mySite
/mySite2
web.config
Folder structure:
/mySite2
mySite.dll
web.config
各自的 web.Config 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="mySite" inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mysite\mySite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
<location path="mySite2" inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mySite2\mySite2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
和
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mySite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
<location path="mySite2" inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mySite2\mySite2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
最佳答案
是的。您可以在一个 Web 应用程序上使用 virtual directory.
来运行两个应用程序。
来自文档:
Virtual Directories are supported for Azure Websites. See Configuring Azure Websites for what you can do through the Azure Management Portal. From the Azure Portal, click on the Website and go to Configure, then scroll down to virtual applications and directories (the last config section). Just enter your virtual directory and the physical path relative to the site root and click Save.
关于azure - 是否可以在一个 Web 应用程序中拥有 2 个 ASP.NET Core 站点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58508658/