-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
For the past few days I've been trying to solve this issue, but I can't ever seem to nail down what the exact problem is...
I have an MVC application and a Web API application hosted on the same IIS Website on a server. I have RedirectToAction() calls within the MVC application that are throwing 502 errors:
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
I have Integrated Windows Authentication enabled on the applications, and I am running WindowsIdentity.RunImpersonated() for all of the WebAPI calls so that the authentication is forwarded properly. I upgraded to 1.1.1 SDK today (I was using 1.1.0), as well as from VS17 RC2 -> VS17 Enterprise but that still hasn't fixed the problem.
The 502s are ONLY happening in my Create/Update actions on the MVC application (E.g. someone creates a new incident, and then is redirected to the view to see that specific incident, or that incident is updated and redisplayed). You can find code samples on my Stackoverflow thread (here), which has sadly died out and thus why I am here. I have exhausted all google searches to find issues not relevant to my specific case, or unrelated to IIS specifically.
I also can't even identify if this is a framework issue or an IIS issue, because the AspNetCore Module Logging says that the 302 Redirect goes through fine, and then a GET request to the view returns a 200 response. I have another 1.0.3 ASP.NET Core application running on the server that has never had this issue before.
If you need any more information please ask, this issue is driving me insane, and is the one thing holding this system back from going into production.
EDIT: I sat down and looked through the logs a bit closer and tracked an entire request from the Home/Index page all the way to the error. This is where I think the request is failing out. In a normal ControllerActionInvoker to the TIM.MVC.Controllers.IncidentsController.View, there is a ViewResultsExecutor that would execute ViewResults running at the View, but here after the 302 redirect, that doesn't seem to be happening. Any thoughts on why that may be?
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 POST http://snaptest.fwcs.k12.in.us/tim/Incidents/SaveIncident?incidentId=58 application/x-www-form-urlencoded 763
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]
Authorization was successful for user: FWCS\mccora01.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
Executing action method TIM.MVC.Controllers.IncidentsController.SaveIncident (TIM.MVC) with arguments (58, TIM.API.Models.Incident) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.Internal.RedirectResultExecutor[1]
Executing RedirectResult, redirecting to /tim/Incidents/View/58.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action TIM.MVC.Controllers.IncidentsController.SaveIncident (TIM.MVC) in 1397.8175ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 2097.562ms 302
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://snaptest.fwcs.k12.in.us/tim/Incidents/View/58
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]
Authorization was successful for user: FWCS\mccora01.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
Executing action method TIM.MVC.Controllers.IncidentsController.View (TIM.MVC) with arguments (58) - ModelState is Valid