1

UPDATED

I refactored the entire question, because now, I Know what are happening, Thx to Daboul

When I start the ASP.Net Core exe inside the VS15 or even on a cmd line with dotnet run it's work fine, but when I try to double click on the exe to run, it's doesn't find the .cshtml.

The weird part, is that the files are there, and are found when executed by vs15

Can someone explain to me what I'm doing wrong?

I just create an Asp.net Core Web App and changed the project.json to produce the .exe like here and here

Community
  • 1
  • 1
Nicollas Braga
  • 802
  • 7
  • 27
  • An HTTP 500 error means there's some basic configuration issue preventing the site/app from starting, or internal failure occurring once the application has started. That's the dreaded "Internal Server Error" code, and if you look in the logs you might see more detailed reasons for the failure. The fact that you received the HTTP 500 error is, actually, proof that your app *was* actually listening on port 5000, or you wouldn't have seen that reply... – David W Feb 17 '17 at 17:09
  • Unfortunately there has no log, I can't figure out what i should do, because by what i saw, the VS15 just run the .exe like run by hands, and when i try to run this by hand, it's throw http 500, and by vs15 it's work – Nicollas Braga Feb 17 '17 at 17:18

2 Answers2

2

Visual Studio and dotnet run run your application in the folder where your code exist. It means it can access the Views folder and the .cshtml files you are editing when you are coding.

However when your run your .exe application, you do it from the publication folder, for exemple ...\Visual Studio 2015\Projects\MySolution\src\MyProject\bin\Debug\netcoreapp1.0\publish I would advice you to go to this folder and check that the folder Views exist. If it does not, it means you just need to publish your views by adding "**/*.cshtml" in your project.json:

"publishOptions": {
    "include": [
        "wwwroot",
        "**/*.cshtml"
    ]
  }

Then publish again with dotnet publish or your previous method. It should fix your problem.

Just for knowledge: It is now possible to precompile all the views with .NET Core 1.1. It means there would be no need to publish the .cshtml files.

Guillaume S.
  • 1,515
  • 1
  • 8
  • 21
1

You can see that one is running in development (the one working) while the other one is running in production. You should first try to remove this difference, see if it fixes the issue. I use a MYEXE_DEV.bat file to do that:

setlocal
set ASPNETCORE_ENVIRONMENT=development
yourbinary.exe
endlocal

Give it a try.

UPDATE: Ok, let's try to move forward a bit then. When you launch you app by pressing F5 in Visual Studio, VS usually (it might depend on your template I guess) uses a launchSettings.json file with several launch profile, for instance below I have two predefines profiles IISExpress and WebApplication1, and in the .json file you might have parameters that explain why it's working under VS, but not when just double clicking on the exe.

enter image description here

Daboul
  • 2,635
  • 1
  • 16
  • 29
  • thix, this make it's show the error: ``InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Home/Index.cshtml /Views/Shared/Index.cshtml`` – Nicollas Braga Feb 17 '17 at 17:29
  • Hi. I tried to update with a suggestion, hopefully it can help. – Daboul Feb 17 '17 at 21:14