Diagnosing issue with .netcore2 web application - An error occurred while processing your request.
The issue at hand
The background for this article.
This is first time I have deployed .netcore2 web application with angular 4. After encountering couple issues with web deployment configuration I have finally deployed my application to target website.
In this article I will cover my process of resolving the issue.
Solutions and mistakes
after searching internet for a while, I was wondering what I am searching for. I know that .net core does logging from configuration.
Therefore the question is: How do I enable logging.
Enabling logging for .NETCORE
In my case I am my application behind IIS. My application is piped through IIS which means that I can log the request out to a file. In order to do that I need to follow the following steps:
Open your web.config
Create a logs folder
Unfortunately, the AspNetCoreModule doesn’t create the folder for you by default
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.
The “stdout” part of the value “.\logs\stdout” actually references the filename not the folder. Which is a bit confusing.
Run your request again, then open the \logs\stdout_*.log file
<aspNetCore processPath=”.\YourProjectName.exe” stdoutLogEnabled=”true” stdoutLogFile=”.\logs\stdout” />
Note – you will want to turn this off after you’re done troubleshooting, as it is a performance hit.
So your web.config’s aspNetCore element should look something like this
<aspNetCore processPath=”.\YourProjectName.exe” stdoutLogEnabled=”false” stdoutLogFile=”.\logs\stdout” />
Now we have information what is wrong, we can proceed with fixing it.
Does plain .netcoreapp2 work
Next I want to run a test if just .netcoreapp does work. Therefore I have jumped into my VisualStudio and create a blank .netcore2 application.
I have used same publish settings and clicked publish. After while I have deployed default version of default application template in release mode.
This means that .netcore is installed correctly and I can concentrate on working on the next step.
Isolating error from the exception
Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Prerendering failed because of error: TypeError: Cannot read property 'Node' of undefined
at module.exports.d.(anonymous function) (netcore2AppPath\ClientApp\dist\vendor.js:26869:26)
at Object.<anonymous> (netcore2AppPath\ClientApp\dist\main-server.js:16696:83)
Current directory is: netcore2AppPath
What does the exception says.
Prerendering failed because of error: TypeError: Cannot read property 'Node' of undefined at ClientApp\dist\vendor.js:26869:26
Lets have a look at the code in this file
And finally isolating the issue to the code
This means it refers to installation of node path. Which is not installed on my server. So simple installation will resolve the issue.
I hope it helped.