Demystifying the Deployment of a .NET 6 Application on Windows Server with IIS ๐Ÿš€

Mastering .NET 6 Application Deployment on Windows Server with IIS: Solving the HTTP Error 500.31 Puzzle

ยท

3 min read

Introduction

๐Ÿ“ Deploying a .NET 6 application on a Windows server with IIS can be a thrilling yet challenging task. In this blog post, we will explore the steps our team followed, the hurdles we encountered, and the solution that ultimately led to success.

Join me on this journey as we unravel the mystery of the elusive "HTTP Error 500.31 - Failed to load ASP.NET Core runtime." ๐Ÿ•ต๏ธโ€โ™‚๏ธ

Deployment Steps ๐Ÿ“ข

Let's look at the high-level steps that we followed to build and deploy the .NET 6 WebAPI.

Step 1: Installing the Latest ASP.NET Core Hosting Bundle ๐Ÿ’ป

The first step we took was installing the essential ASP.NET Core Hosting bundle from Microsoft Official. At the time of our deployment, .NET 7 was the latest, and we downloaded the bundle from the link.

Take a look at the screenshot below highlighting the Hosting Bundle area.

Downloading the ASP.NET Core Hosting Bundle 7.0

Step 2: Publishing the .NET 6 WebAPI Project ๐Ÿš€

With the Hosting Bundle installed on our local machine, we proceeded to publish the .NET 6 WebAPI project as a framework-dependent build. This process ensures that the application will run seamlessly on the target server.

Check out the screenshot below to get a glimpse of the publish settings.

Framework Dependent Deployment Mode .NET

Step 3: Moving Artefacts to the Windows Server ๐Ÿ“‚

Once the build artefacts were generated, we transferred them to the Windows Server, preparing for the deployment process.

Step 4: IIS Configuration and Application Pool Setup โš™๏ธ

To deploy the application, we followed the typical IIS steps, creating a new Application Pool with the .NET CLR version set to "No Managed Code". This configuration is crucial for running .NET Core applications in IIS.

Have a look at the screenshot below for an example of this setup.

IIS Application Pool No Managed Code

Encountering the Mysterious HTTP Error 500.31 โ“

Despite our meticulous preparation, we faced an unexpected roadblock when browsing the application from IIS. The dreaded "HTTP Error 500.31 - Failed to load ASP.NET Core runtime" message appeared, leaving us puzzled. The Hosting Bundle installation should have included the necessary runtime, but it seemed unclear why it failed.

Here is the screenshot of the error from the browser.

HTTP Error 500.31

Unravelling the Solution ๐Ÿ’ก

Undeterred, we launched into extensive research and tried various approaches involving the Application Pool and IIS settings, but to no avail. It wasn't until we stumbled upon online discussions about the Hosting Bundle's backward compatibility that we gained a breakthrough.

The Missing Piece ASP.NET Hosting Bundle 6 โœจ

After multiple trials and errors, we finally achieved success by installing the ASP.NET Hosting Bundle 6. This seemingly simple step proved to be the key that unlocked the solution, resolving the enigmatic HTTP Error 500.31.

Downloading the ASP.NET Core Hosting Bundle 6.0

Conclusion

Our journey to deploy a .NET 6 application on a Windows Server with IIS was a rollercoaster of challenges and discoveries. By sharing my experiences and uncovering the importance of using the compatible Hosting Bundle, I hope to save you from similar headaches during your own deployments.

๐ŸŒŸ Feedback

I'd love to hear your thoughts! Leave a comment below if you found this blog post helpful or if you have any questions.

Happy deploying! ๐Ÿ˜Š

Did you find this article valuable?

Support Tadit Dash by becoming a sponsor. Any amount is appreciated!

ย