Why does upgrading to .Net 6 causes HTTP Error 500.31 - Failed to load ASP.NET Core runtime

Viewed 3104

I created a .net core 3.1 application. Then migrated to .Net 5 and wasm. I can deploy it to a server running .net core 3.1 and 5.0 hosting bundles.

Now I upgraded my .net 5 wasm to .net 6. It runs fine locally. When I deploy to a web server running .net 6 hosting bundle only, the application returns the error : HTTP Error 500.31 - Failed to load ASP.NET Core runtime

Seems like i would need to install .net 3.1.

I can't find any reference to .net 3.1 in my code.

Did I miss something in my upgrade? I 'upgraded' by opening my solution in VS2022, changing the target framework to 6.0 updating all my Nuget packages to the latest.

Build, run.

2 Answers

I don't know why but creating a new application pool solved my issue.

After a long search my problem was in my .runtimeconfig.json file

For some reason it still had "version" : "5.0.0". My fix.

"runtimeOptions": {
"tfm": "net5.0",
"framework": {
  "name": "Microsoft.AspNetCore.App",
  "version": "6.0.2"
},
Related