Azure上的Asp.Net Core 2.0得出502.5

编程入门 行业动态 更新时间:2024-10-28 14:23:56
本文介绍了Azure上的Asp.Net Core 2.0得出502.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个小型Web应用程序,它使用Azure上部署的Asp.Net Core 1.1开发,并且运行良好.我刚刚将项目迁移为使用Asp.Net Core 2.0,并尝试将其部署在Azure上.部署进行得很好,但是当我打开站点时,出现了502.5错误.当我检查Azure日志流时,出现以下错误:

当CGI应用程序未返回有效集时,将发生此错误 的HTTP标头,或者当代理或网关无法发送 向父网关的请求.您可能需要获取网络跟踪或 如果不是CGI问题,请与代理服务器管理员联系.

不用说它可以在我的开发机器上使用相同的代码很好地工作.请注意,尽管我在Azure上停用了数据库创建(以检查是否不是原因),但我也在使用Entity Framework Core 2.0.

有关信息,我从1.1迁移到2.0的方法是将目标框架设置更改为"netcoreapp2.0",并使用NuGet包"Microsoft.AspNetCore.All".可以肯定的是,我还删除了我的发布配置文件,然后重新创建了一个.

Asp.Net Core 2.0是否可能在Azure上不可用?我对Asp.Net Core相当陌生,所以我不知道Azure何时提供新版本.

编辑

当我尝试通过natemcmaster提出的调试控制台通过dot net CLI运行我的应用程序时,出现以下问题:

未处理的异常:System.IO.FileLoadException:无法加载文件 或程序集"Microsoft.AspNetCore.Hosting.Abstractions", 版本= 2.0.0.0,文化=中性,PublicKeyToken = adb9793829ddae60'. 找到的程序集的清单定义与程序集不匹配 参考. (来自HRESULT的异常:0x80131040)

我将DLL下载到我的桌​​面上,并使用Dot Net Peak检查版本,确实,DLL是1.1.2,尽管我使用Visual Studio创建了项目并直接将其发布,所以Visual Studio是否存在问题?还是Nuget?

解决方案

问题实际上出在以下事实上:首先,我的Web应用使用的是 core 1.1,它将所有DLL部署在"wwwroot"中Web应用程序的文件夹.但是,使用asp core 2.0,由于从全局存储库中提取了DLL,因此不再执行此操作.但是,由于Visual Studio不会在发布之前清除目标文件夹,所以我最终遇到了1.1 DLL位于我的wwwroot中的情况,因此网站选择了这些文件夹而不是store文件夹中的2.0 DLL./p>

这在这里有更详细的解释: github/Azure/app-service-announcements-discussions/issues/2#issuecomment-313816550

I have a small web app developed with Asp.Net Core 1.1 deployed on Azure and it works well. I just migrated the project to use Asp.Net Core 2.0 and tried to deploy it on Azure. The deployment went fine but when I open the site, I get a 502.5 error. When I check my Azure log stream, I get the following error:

This error occurs when a CGI application does not return a valid set of HTTP headers, or when a proxy or gateway was unable to send the request to a parent gateway. You may need to get a network trace or contact the proxy server administrator, if it is not a CGI problem.

Useless to say that it works well on my development machine with the same code. Note that I'm also using Entity Framework Core 2.0 although I deactivated the database creation on Azure (to check if it was not the cause).

For information, the way I migrated from 1.1 to 2.0 is by changing the target framework settings to "netcoreapp2.0" and by using the NuGet package "Microsoft.AspNetCore.All". Just to be sure, I also deleted my publish profile and recreate one.

Is it possible that Asp.Net Core 2.0 is not yet available on Azure ? I'm fairly new to Asp.Net Core, so I don't know when new releases are made available on Azure.

EDIT

When I try to run my app with dot net CLI via the debug console as proposed by natemcmaster, I got the following issue:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I downloaded the DLL on my desktop and check the version with Dot Net Peak and indeed, the DLL is 1.1.2, although I created the project with Visual Studio and directly publish it, so is it an issue with Visual Studio ? Or Nuget ?

解决方案

the issue was actually coming from the fact that, at first, my web app was using core 1.1, which deploys all the DLL in the "wwwroot" folder of the web application. However, with asp core 2.0, it does not do that anymore as the DLL are picked up from a global store. However, as Visual Studio does not clean the destination folder before a publish, I ended up with a situation where the 1.1 DLL were in my wwwroot, so the web site was picking up these ones instead of the 2.0 ones in the store folder.

This is explained in more details here: github/Azure/app-service-announcements-discussions/issues/2#issuecomment-313816550

更多推荐

Azure上的Asp.Net Core 2.0得出502.5

本文发布于:2023-11-04 06:00:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557138.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Net   Asp   Azure   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!