Upgrading from .net 5 to .net 6 has broken the static files rendering in Development mode

Puneeth K 25 Reputation points
2023-05-27T07:45:36.03+00:00

We have web application hosted in kubernetes has issues rendering the static files when "ASPNETCORE_ENVIRONMENT" set to "Development". The same code works if the "ASPNETCORE_ENVIRONMENT" is set to "Production" The issue started appearing after upgrading to .net 6 from .net 5.

Gettig the below error unhandled exception. System.IO.DirectoryNotFoundException: /src/src/Web/DWC.WebStatus/wwwroot

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,409 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,872 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,294 questions
0 comments No comments
{count} votes

Accepted answer
  1. Boris Von Dahle 3,116 Reputation points
    2023-05-29T10:51:25.92+00:00

    Hello,

    The error message System.IO.DirectoryNotFoundException: /src/src/Web/DWC.WebStatus/wwwroot indicates that the system is not able to find the directory at the specified path. This could be due to several reasons including incorrect path, missing direcotry or file system permissions.

    As the issue is only happening in the "Development" environment, there might be something in your development environment configuration that's causing the issue. you should heck your appsettings.Development.json file.

    If your wwwroot directory is not being included in your Docker image, or if the path to the directory in the image is not what your application expects, you will see this error. Check your Dockerfile to ensure that the wwwroot directory is being included in the image, and that the path in the image matches what your application expects.

    In .NET, the IWebHostEnvironment.WebRootPath property can be used to get the absolute path to the wwwroot directory. If your application is using a hard-coded path to access the wwwroot directory, it might not work correctly in a Docker/Kubernetes environment, where the file system layout can be different from what it is on your development machine.

    If that doesn't solve the issue, you might need to provide more information, like your project files, or any relevant parts of your Kubernetes configuration.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful