Azure虚拟目录中的多个站点 [英] Azure multiple sites in virtual directories

查看:81
本文介绍了Azure虚拟目录中的多个站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个需要部署在同一域中的asp.net核心站点(子域无法使用我的SSL证书).

I have 3 asp.net core sites I need to deploy on the same domain (subdomains will not work with my SSL certificate).

  • https://my-site.com (Single page app)
  • https://my-site.com/api (Web api)
  • https://my-site.com/identity (Identity server)

当我部署api和Identity项目时,它们可以正常工作.但是,在部署单页应用程序时,api和身份将停止工作.

When I deploy the api and identity projects, they work fine. However, when deploying the single page app, api and identity stop working.

The page cannot be displayed because an internal server error has occurred.

该错误会立即出现,因此我认为它可能在启动初期就失败了. 单页应用程序可以正常运行.

The error appears instantly so it's probably failing early on from startup I guess. The single page app is working ok.

似乎是温泉干扰了,我尝试了

It seems the spa is interfering, I tried solutions from here to ignore the routes, but I get the same error.

我在此处尝试了解决方案,以获得更具描述性的错误,但无济于事.

I have tried the solution here to get a more descriptive error but to no avail.

不确定从这里去哪里

推荐答案

问题的原因是根应用程序和子应用程序都添加了aspNetCore处理程序,从而导致配置系统崩溃.您可以通过在Azure门户中打开详细的错误消息,然后在D:\home\LogFiles\DetailedErrors下找到错误页面来查看此内容.您会看到此错误:

The cause of the problem is that both the root application and the child app add the aspNetCore handler, causing the config system to blow up. You can see this by turning on Detailed error messages in the Azure Portal, and then finding the error page under D:\home\LogFiles\DetailedErrors. You'll see this error:

无法添加类型为添加"的重复集合条目,且其唯一键属性名称"设置为"aspNetCore"

Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'aspNetCore'

有两种解决方法.

第一个是使用location标记来防止继承.具体来说,请通过以下方式更改根应用的web.config:

The first is to use a location tag to prevent inheritance. Specifically, change your root app's web.config from something like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\myapp.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
  </system.webServer>
</configuration>

类似这样:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\myapp.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
    </system.webServer>
  </location>
</configuration>

第二种方法是从 sub 应用程序中删除<handlers>部分,以避免重复(如

The second approach is to remove the <handlers> section from the sub-application to avoid the duplication (as suggested in the doc under Configuration of sub-applications):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <aspNetCore processPath="dotnet" arguments=".\mySubApp.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
  </system.webServer>
</configuration>

这篇关于Azure虚拟目录中的多个站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆