Reputation: 7555
I have ASP.Net Core 2.2
application. This is running fine when running from Visual Studio (Both Debug & Release mode)
But when I deploy the same to IIS in any machine, it's throwing 500 error.
"MessageTemplate": "Unexpected exception in IISHttpServer.HandleRequest.", "Exception": "System.NullReferenceException: Object reference not set to an instance of an object.\r\n at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.GetOriginalPath()\r\n at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.InitializeContext()\r\n at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()\r\n at Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer.HandleRequest(IISHttpContext context)", "Properties": { "SourceContext": "Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer" }
On Googling, the only link:
https://github.com/aspnet/AspNetCore/issues/6075
Note I am running the app in IIS, with StartMode
set to OnDemand
.
What's causing this error & how to get rid of this? Thanks!
Upvotes: 2
Views: 15245
Reputation: 7555
When the application loads either in IIS Express or IIS, the Swagger Document was running with no issue.
I doubted if it's really something to do with .Net Core 2.2
& IIS
compatibility.
So I created a sample Controller as below.
public class SampleController : ControllerBase //.Net Core 2.2
{
[HttpGet]
public async Task<IActionResult> Get()
{
return Ok("APIs up & running");
}
}
Ran the above API from Visual Studio & then deployed the same on IIS with both preload = true & then false
With no surprise, API ran with no issue.
In the actual application, I was using AWS (Cognito)
& somewhere in the recent past I had came across some article where it was mentioned AWS supports .Net Core 2.1
As the application is in its initial phase of development, so we tried to check the same API
with .Net Core 2.1
Again as no surprise, the same set of APIs ran with no issues.
So in my case, it was AWS Cognito
(or other services) yet don't support .Net Core 2.2
This is how this issue got resolved.
Upvotes: 0
Reputation: 23820
As per the link in your question, you could consider disabling preload (as a short term measure until the underlying bug is fixed).
i.e. change that True
to False
.
Upvotes: 2