I have an application developed in asp.net core with full .net framework (.Net 4.6.1). The application is created using Visual Studio 2017 RC. After successful compilation, it has generated TestApplication.exe.
When I go to the project root directory and executes the command dotnet run, application is launched and starts listening on port 5000. Application runs fine using this method. However when I go to the projectRoot\ bin\Debug\net461\
and launch TestApplicatin.exe, it starts listening on port 5000 too but when I go to the browser and type http://localhost:5000 , I get the following error
The localhost page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
Note -
Please see the content of Program.cs file
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
Found the problem. I was running exe without publishing it. So bin directory contained only exe (i.e. TestApplication.exe) without wwwroot folder. It was not able to find the required files and hence the fatal error was occurring. If you want to run asp.net core application without IIS (i.e. Self Hosted App using Kestrel) following are the correct steps
launch the exe from command prompt or double clicking on it. After publishing exe was located at the following path in my case
bin\Debug\net461\win7-x86\publish\TestApplication.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With