.NET Core 2.2 Publishing problems - asp.net-core

I have a web hosting which supports ASP.NET Core 2.2. I tried to publish my own asp.net core 2.2 project in it and it worked with just design. And then I added Identity in the project and I added the same database in the host (exported and imported db which created with migrations). I changed the database connection as well, but when I'm trying to publish the same project it gives me this error :
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681
Here is my connection string :
"ConnectionStrings": {
"IdentityConnection": "Data Source=.\MSSQLSERVER2016;Database=ChatIdentity;Integrated Security=False;User ID=halitkal;Password=*;Connect Timeout=15;Encrypt=False;Packet Size=4096"
},
Here is my webconfig file :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\ChatSite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 028aa0e3-c5ef-4f5c-87ac-e8de39c5ca44-->

Turn on the stdout logs by changing the next line in the web.config
aspNetCore processPath="dotnet" arguments=".\ChatSite.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
Don't forget create a folder named logs in the same directory that you have your dll files.
Then reboot the application (Application pool if you´re hosting in IIS) then make an http request and then check for generated log, that should give to you the detail about the error.
If that not works, make sure you have the right runtime installed.

Related

How to fix HTTP Error 500.31 - Failed to load ASP.NET Core runtime

I'm trying to publish .NET core 5.0 application to IIS but always having errors!
I already tried every single response on StackOverflow and no one works for me .
The last error :
HTTP Error 500.31 - Failed to load ASP.NET Core runtime
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more guidance on diagnosing and handling these errors, visit Troubleshoot ASP.NET Core on Azure App Service and IIS.
My web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\AppCore.dll" stdoutLogEnabled="false" hostingModel="inprocess" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
dotnet --info
There could be any number of errors during start up that is causing your problem. When I first faced this issue, enabling logging and viewing that put me in the right direction.
Enable logging by editing your deployed web.config file.
<aspNetCore processPath="dotnet"
arguments=".\AppCore.dll"
stdoutLogEnabled="true" *** <<< change this
hostingModel="inprocess"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false"/>
Then ...
Recycle your server application
Make a request to your server application
This should cause the previous error
Have a look on your server for log file in logs\stdout*
The log file should give you some pointers
If this doesn't nail it first time, you might need to add some extra logging on the server based on the pointer from step 5.

Deploy ASP.NET Core Web API on IIS 10 [duplicate]

I developed a web api in asp.net core version 1.0.1 using visual studio 2015, when I published the web api in IIS 10 of the same pc where it was developed, everything works correctly. The problem arises when I copy and paste the publication folder of the web api to a different pc, the browser shows the error 500.19 Internal Server Error, error code 0x8007000d, "The requested page can not be accessed because the related configuration data for the page is invalid ", which leads to some problem in the web.config.
I do not think the version of IIS is the problem because moving from IIS 10 to IIS 8 or from IIS8 to IIS 10 gives the same error, and the same happens between two pcs with IIS 10.
I have already reviewed several related issues, like, The element 'system.webServer' has invalid child element 'aspNetCore', and others related to web.config file where it seems the error is found. The web.config file in the development environment is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
After publish the web api, the web.config file looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\buildingSecureWebApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
This web.config file has the same content no matter what computer was publish.
Some idea of ​​what the solution to my problem may be, I need to mount the web api in any version of windows and until now it only works correctly on the pc that was developed.
To get a more detailed error message:
Verify that the log directory exists at the path referenced by the web config. If it does not, create it. The path shown in your config would place the "logs" directory in the root folder of the deployed site.
Verify that the application pool has write access to the logs directory and
Verify that `stdoutLogEnabled="true".
If you have verified all 3 of these items, then you should get log entries that will contain a more detailed description of the error
What could cause a "500.19 Internal Server Error, error code 0x8007000d" error?
.NET Core hosting bundle is not installed on the webserver where the site is deployed. To remedy this, obtain this download .NET Core Windows Server Hosting bundle
You may also want to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.
Control Panel > System > Advanced System Settings > Environment Variables. highlight "Path", click 'Edit' and verify that the path to the dotnet folder is present. If it isn't, add it. Do the same for both the User variables and System variables. Restart your machine and try again.

IIS cannot open web.config - The requested page cannot be accessed because the related configuration data for the page is invalid

I'm trying to deploy new asp.net core 5 (5.0.100-rc.1.20452.10) app to IIS on Win 10 and Windows Server 2019.
I've deployed the app using Visual Studio to Default Web Site with ApplicationPoolIdentity and granted full access permission to both "IIS_IUSRS" and "Everyone".
I'm still getting:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
When I try to open the config in IIS Manager I get "Data is invalid" error:
The webconfig looks pretty normal:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
I think I've installed all IIS Features:
I had the same issue, while deploying net core 6 application.
I gave the IUSR and IIS_IUSR permissions.
I installed the URL rewrite extension.
The thing finally saved me was I checked for if net core hosting was installed on my system, we can verify in system registry under:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Updates.NET Core path
like screenshot below.
And I fixed it after downloading the hosting module:
.Net hosting bundle
And now the settings and application works fine.

500 error : Unable to get required configuration section 'system.webServer/aspNetCore'

I have an internal server error at my .NET Core web service launch. Tuesday morning, the web-service was lauching well, Tuesday afternoon a windows update has been installed (KB4570720 package), Wednesday I have this 500 error...
The IIS error page tell me :
Module AspNetCoreModuleV2
Notification ExecuteRequestHandler
Gestionnaire aspNetCore
Code d'erreur 0x80004005
And IIS log event has this specific error :
Could not load configuration. Exception message: Unable to get required configuration section 'system.webServer/aspNetCore'. Possible reason is web.config authoring error.
This my web.config, I don't see what's wrong.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\loemail.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
<environmentvariables />
</aspNetCore>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
I have tried to change the encoding from UTF8 to ANSI.
I've tried to change the stdoutLogEnabled from false to true but there is no error there since it occurs before.
I've tried to remove completely the web.config and copy-paste the one from my backup.
I've tried to reinstall the web-service.
I have another .NET Core application running on this server, so I excluded issues with the .NET framework version but maybe I'm wrong? How could I check that? Both use .NET Framework 2.2.
Should I remove the last windows update package?
I fix the problem by copy/paste the web.config from my other application... And I still see no difference between them ! Computer makes us crazy sometimes...

How to enable logging in published asp.net Core projects?

I published my asp.net core web api in a iis serveur , when i test in the browser the application i get an 502.5 error.
i searched on how to find a solution , i found that i need to enable logging by changing the stdoutLogEnabled="false" to true.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="true">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\WsAZProjet.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: baf7ef69-c0ff-4e36-b69c-71ad3fd869b9-->
i changed that in iis serveur and retested the app in the browser but i didn't get the log directory generated , so i think i should configure that in code and then republish the app ?
do you have an idea on how to enable logging for published apps ?
should i restart iis for that to work ?
Update
After searching , i found here that i need to manualy create the logs folder , i did that and tested again the app , i get a log_stdout file under the folder but it is empty !!?
Solved , here the reason of the error :
Incorrect proecessPath, missing PATH variable, or dotnet.exe access violation
Browser: HTTP Error 502.5 - Process Failure
Application Log: Failed to start process with commandline ‘“dotnet” .\my_application.dll’ (portable app) or ‘”.\my_application_Foo.exe”’ (self-contained app), ErrorCode = ‘0x80070002’.
ASP.NET Core Module Log: Log file created but empty
Troubleshooting:
Check the processPath attribute on the element in web.config to confirm that it is dotnet for a portable application or .\my_application.exe for a self-contained application.
For a portable application, dotnet.exe might not be accessible via the PATH settings. Confirm that C:\Program Files\dotnet\ exists in the System PATH settings.
For a portable application, dotnet.exe might not be accessible for the user identity of the Application Pool. Confirm that the AppPool user identity has access to the C:\Program Files\dotnet directory.
my processPath was set by me yesterday to C://ProgramFiles/dotnet.exe , changing that to just dotnet solve the issue and i get my log file informations now.