Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.Net Core-IISHttpServer.HandlerRequest中出现意外异常_C#_Asp.net Core_Iis - Fatal编程技术网

C# ASP.Net Core-IISHttpServer.HandlerRequest中出现意外异常

C# ASP.Net Core-IISHttpServer.HandlerRequest中出现意外异常,c#,asp.net-core,iis,C#,Asp.net Core,Iis,我有ASP.Net Core 2.2应用程序。从VisualStudio运行时(调试和发布模式)运行良好 但当我在任何机器上将其部署到IIS时,都会抛出500个错误 “MessageTemplate”:“中出现意外异常” IISHttpServer.HandlerRequest。”, “异常”:“System.NullReferenceException:对象引用未设置为对象的实例。\r\n在 Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext

我有
ASP.Net Core 2.2
应用程序。从VisualStudio运行时(调试和发布模式)运行良好

但当我在任何机器上将其部署到IIS时,都会抛出500个错误

“MessageTemplate”:“中出现意外异常” IISHttpServer.HandlerRequest。”, “异常”:“System.NullReferenceException:对象引用未设置为对象的实例。\r\n在 Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.GetOriginalPath()\r\n 在 Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.InitializeContext()\r\n 在 Microsoft.AspNetCore.Server.IIS.Core.IISHTTPContextroft`1.ProcessRequestAsync()\r\n 在 Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer.HandlerRequest(IISHttpContext 上下文“, “财产”:{ “SourceContext”:“Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer” }

在谷歌上,唯一的链接是:

注意:我正在IIS中运行应用程序,将
StartMode
设置为
OnDemand

是什么导致了这个错误&如何消除这个错误? 谢谢

> P>,您可以考虑<强>禁用/强>预加载(作为一个短期措施,直到基础错误被修复)。< /P>


i、 e.将
True
更改为
False

当应用程序在IIS Express或IIS中加载时,Swagger文档运行时没有问题

我怀疑这是否真的与
.netcore2.2
&
IIS
兼容性有关

因此,我创建了一个示例控制器,如下所示

public class SampleController : ControllerBase //.Net Core 2.2
{
 [HttpGet]
 public async Task<IActionResult> Get()
 {
    return Ok("APIs up & running");
 }
 }
public类SampleController:ControllerBase/.Net核心2.2
{
[HttpGet]
公共异步任务Get()
{
返回Ok(“API启动并运行”);
}
}
从VisualStudio运行上述API,然后在IIS上部署相同的API,预加载分别为true和false

毫不奇怪,API运行时没有问题

在实际应用程序中,我使用的是
AWS(Cognito)
&在最近的某个时候,我遇到过一些文章,其中提到了AWS支持
.netcore2.1

由于应用程序处于开发的初始阶段,因此我们尝试使用
.NETCore2.1
检查相同的
API

同样,毫不奇怪,相同的API集运行时没有出现任何问题

所以在我的例子中,它是
AWS Cognito
(或其他服务),但不支持
.Net Core 2.2

这就是解决此问题的方法。

您正在运行此模块吗?