Resolving Internal Server Error While Migrating ASP.NET Core Project

In this article, you will learn how to resolve the error that occurs while trying to run an ASP.NET Core project copied from one machine to another machine.

Problem

I have created an ASP.NET Core project using the project template in Visual Studio 2015 on my laptop machine. It was working properly on my laptop. Then, I copied that same solution from my laptop to desktop machine and tried to run the project. When I tried to run the project, I got a 500 Internal Server Error as shown below (F: 1). But the same solution was working properly on my laptop.


Analysis of Error Message

When I copied the solution folder from my laptop to desktop machine, a hidden folder ".vs" also got copied. When I looked at the error message closely, I found that it was displaying the config file location as the location of that file on my laptop, as shown below (F: 2).

/article/resolving-internal-server-error-while-migrating-asp-net-core-project/Images/image002.gif
So, to fix this issue, there are two solutions.

Solution

  • Close the solution and reopen it in Visual Studio 2015 on new machine.
  • Change the physical path for the solution in applicationhost.config file.

The first solution is very easy. For the second solution, first we need to close Visual Studio 2015. To change the physical path for the solution in applicationhost.config file, open the applicationhost.config file located under .vs/config folder and search for term “sites”. It is an XML file.

Under sites node, locate the site node where the physical path for the solution is specified and binding information contains the same port number as your application is trying to run on, as shown below.

  1. <site name="WebApplication6" id="2">  
  2.     <application path="/" applicationPool="Clr4IntegratedAppPool">  
  3.         <virtualDirectory path="/" physicalPath="c:\users\admin\documents\visual studio 2015\Projects\WebApplication6\src\WebApplication6" /> </application>  
  4.     <bindings>  
  5.         <binding protocol="http" bindingInformation="*:58089:localhost" /> </bindings>  
  6. </site>  
Then, I just changed the physical path value to the actual physical path of the solution on my desktop machine. Then, everything started to work.

The first solution is also similar to the second solution because when we reopen the project in Visual Studio 2015, Visual Studio will change the solution path in applicationhost.config file according to the new physical path of the solution on a new machine. But if it doesn’t work, we need to follow the second solution and change that path manually.

Conclusion

In this article, we talked about how to resolve the 500 Internal Server Error when trying to run an ASP.NET Core project copied from one machine to another machine. I hope you enjoyed reading the article.

Happy Coding and I wish you a Happy New Year!