问题
I'm in the process of diagnosing this issue and I will update as I learn more but I wanted to post what I have in case there's a quick fix/someone's seen this already.
I have a MVC5 project, .NET 4.5.2, Visual Studio 2015. I recently started using C# 6 so in order to get Razor to work I had to install the CodeDOM compiler Nuget package. Everything works on my local machine (of course it does).
My current stable Azure site is on a Git commit that is NOT using C# 6, but is using .NET 4.5.2 and VS 2015. So the only big difference between my latest commit and the stable commit is the introduction of C# 6 and Roslyn.
When I deploy the new commit to Azure, I consistently get 502 Gateway errors after it spins for up to 2 minutes. On a MVC action that does NOT return a view but a Content action result, it will eventually return content although it's pretty slow. When I go to Kudu and view processes, I can see the Roslyn compiler runs and I was noticing last night that the w3wp process would restart every so often, usually after I get the 502 on requests.
If I redeploy my earlier commit, it works fine.
My next steps really are to isolate the issue to a blank web app using C# 6 and MVC 5, to see if that is the root cause--but my educated guess is the introduction of the Roslyn compiler is messing things up in Azure.
Anyone have any ideas? I'll update this as I learn more, but I have a busy day and weekend ahead.
回答1:
Figured it out, slowly but surely, took me all day. I deployed each commit since the last stable one and found the commit that introduced the issue. In the commit I had introduced some more TypeScript files. Turns out these were NOT compiling in Kudu/Azure and so the JS files were missing, causing my bundling/minification framework (Cassette) to try to resolve references--which it never resolved and caused a StackOverflow or loop issue (separate bug) which caused my w3wp process to crash. This is why it was almost impossible to debug and also why my non-Razor actions returned--they weren't rendering the bundles so it didn't call into Cassette.
I included the generated JS files in the project and that fixed the problem. I think I will just edit my Kudu deployment script and call tsc manually on my tsconfig.json file so it compiles on build properly.
来源:https://stackoverflow.com/questions/34092016/vs-2015-c-sharp-6-mvc5-roslyn-502-gateway-errors-on-azure-web-app