简体   繁体   中英

an error occurred while starting the application after publishing dot net core 2 app

After publishing my .net core 2 app on IIS 7.5 I get this error:

an error occurred while starting the application.

Is there any way to force dot net core to submit a accurate error message rather than such general message?

You can try to start your application directly on your IIS Server via the console.

dotnet myapp.dll

You should get a much more verbose error there.

I found this link helpful: How to troubleshoot: “An error occurred... . In summary:

  1. In the aspNetCore element of your web.config , change the stdoutLogEnabled attribute to true .
<aspNetCore processPath=".\myapp.exe"
            stdoutLogEnabled="true" <!-- this'n -->
            stdoutLogFile=".\logs\stdout" />
  1. Based on the value of stdoutLogFile , create a logs folder in your application root directory. (Note: The stdout part of the path refers to the log file prefix, not a folder in the directory tree.)

  2. Run your request and open the log file.

Additional information on the ASP.NET Core module: ASP.NET Core Module

Don't forget to disable logging once done!

My problem was simply that IIS didn't had permission to write in the folder that the application files were located.

This is a very bad error to get.

Hope it will help somebody and not waste many hours on it.

I followed the following steps when I got the error in our environment after deployment.

Server: Windows Server 2016

IIS Version: 10.0

Step1: Check all configs are upto date

Step2: Verify Cors config. We have enabled cors and the list to allow is part of config.

I was able to solve with these two steps.

After deployment it will be mostly with the appsettings.config. Make sure the config is correct. Hope this helps.

Don't get frustrated as the error doesn't give any clue. To get the error there is a simple way

  1. Open command prompt.
  2. Navigate to your published folder location which is mapped to IIS.
  3. Type dotnet yourapplicationddllName.dll
  4. Now open http://localhost:5000 or https://localhost:5001. This will open your application.
  5. Do your thing. you will get the error in the command prompt console.

This method save me several times when some critical releases gets delayed Cheers

If you deploy the app to the shared hosting, you can not run it via console. therefore I suggest doing the following steps:

  1. Open your web.config
  2. Change stdoutLogEnabled=true
  3. Create a logs folder(Unfortunately, the AspNetCoreModule doesn't create the folder for you by default also If you forget to create the logs folder, an error will be logged to the Event Viewer that says: Warning: Could not create stdoutLogFile \\?\\YourPath\\logs\\stdout_timestamp.log, ErrorCode = -2147024893.)
  4. The “stdout” part of the value “.\\logs\\stdout” actually references the filename, not the folder. Which is a bit confusing.
  5. Run your request again, then open the \\logs\\stdout_*.log file
  6. Have fun ;)

Note – you will want to turn this off after you're done troubleshooting, as it is a performance hit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM