我们有一个针对dnx-clr-win-x86.1.0.0-rc1-update1运行的ASP.NET Core 1.0 RC1应用程序,并作为单独的网站托管在IIS中。这个工作正常。
现在我们要向此Web应用程序添加“子”应用程序,因此两者都在同一端口上运行,但子应用程序应在子路径/Child
中可用。子应用程序是一个普通的ASP.NET 4.5 Web API应用程序。
在ASP.NET 5之前,当主应用程序也是ASP.NET 4.5应用程序时,此设置工作正常。但遗憾的是,它失败了。当我们尝试在浏览器中访问子应用程序时,我们得到了一个:
HTTP Error 502.3 - Bad Gateway
There was a connection error while trying to route the request.
Module httpPlatformHandler
Notification ExecuteRequestHandler
Handler httpplatformhandler
Error Code 0x80070002
这是否与使用httpPlatformHandler托管ASP.NET 5应用程序的新方法有关?如上所述:它适用于主要的ASP.NET 5应用程序,而不适用于子ASP.NET 4.5应用程序。已安装HttpPlatformHandler 1.2。
答案 0 :(得分:0)
是的,httpPlatformHandler会改变这种行为。
我认为您需要使用IApplicationBuilder上的"Map"扩展方法来分支HTTP请求。例如,"配置"中的这段代码。 " Startup"的方法类:
app.MapWhen(context =>
{
return context.Request.Query.ContainsKey("branch");
}, HandleBranch);
然后HandleBranch看起来像:
private void HandleBranch(IApplicationBuilder app)
{
app.Run(async (context) =>
{
await context.Response.WriteAsync("Branch used.");
});
}
然后使用单词" branch"处理所有查询字符串。在里面。您可以捕获子路径" / Child"。
答案 1 :(得分:0)
确保您的ASP.Net 4.5应用程序使用单独的池并且该池是受管理的。 打开ASP.Net Core应用程序的web.config并检查" AspNetCoreModule"的名称,默认情况下它是" aspNetCore"
在ASP.Net 4.5应用程序中打开web.config并将以下内容添加到system.Webserver =>处理程序部分
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore"/>
<!--Your other handlers -->
</handlers>
</system.webServer>
</configuration>