Permissions Hosting .NET Core out-of-process with files on a network drive - asp.net-core-2.2

I have a new .NET Core API which is targeting full .Net framework so is being hosted out of process in IIS. This is working fine locally in Visual Studio, also good in a test environment using IIS, however deploying to production this is not working. The difference I can see is the test environment has a local drive with the API files, and production API files are set with a UNC path in IIS, the App Pool runs as a domain user that has full access to the network folder. The API fails to launch with errors which messages are shown below from the event log, including failing to write to logs stdout. However if I set the App Pool to run as a domain admin account, all is well and the API runs. I can't run as this user though of course, so my question is what permissions or trust levels am I missing here. I am new to .NET Core, so I am unsure what extra permissions may be required. Other full .NET Framework websites and services are running okay on this server with their files on this network drive.
Here are the event log messages when running the App Pool as the non-admin domain user.
Application EventLog for Source: "IIS AspNetCore Module V2" Warning: "Could not create stdoutLogFile \?\UNC\fileclstr\Websites\WebsiteName\API\logs\stdout_20191205204322_15236.log, ErrorCode = '0x800700a1'."
Application EventLog for Source: .NET Runtime Error: "Application: DistributedServices.WebsiteName.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.Sockets.SocketException
at System.Net.Sockets.Socket..ctor(System.Net.Sockets.AddressFamily, System.Net.Sockets.SocketType, System.Net.Sockets.ProtocolType)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.BindAsync()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer+<>c__DisplayClass21_01+<<StartAsync>g__OnBind|0>d[[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context, Microsoft.AspNetCore.Hosting, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder+<BindEndpointAsync>d__3.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions+<BindAsync>d__43.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder+AddressesStrategy+<BindAsync>d__2.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder+<BindAsync>d__0.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer+<StartAsync>d__211[[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context, Microsoft.AspNetCore.Hosting, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Hosting.Internal.WebHost+d__26.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Hosting.WebHostExtensions+d__5.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Hosting.WebHostExtensions+d__4.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(Microsoft.AspNetCore.Hosting.IWebHost)
at DistributedServices.WebsiteName.Program.Main(System.String[])"
Application Eventlog for Source: "Application Error" Error: "Faulting application name: DistributedServices.WebsiteName.exe, version: 1.0.0.0, time stamp: 0xf4041a68
Faulting module name: KERNELBASE.dll, version: 10.0.14393.3321, time stamp: 0x5da7e8d8
Exception code: 0xe0434352
Fault offset: 0x000dc232
Faulting process ID: 0x2bf8
Faulting application start time: 0x01d5abaca2aaaf51
Faulting application path: \fileclstr\Websites\WebsiteName\API\DistributedServices.WebsiteName.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report ID: c68c4bdd-e46d-4628-8be3-63b1f6cc78dc
Faulting package full name:
Faulting package-relative application ID: "
Application EventLog Source: "IIS AspNetCore Module V2" Warning: "Application '/LM/W3SVC/1/ROOT/api' with physical root '\fileclstr\Websites\WebsiteName\API\' failed to start process with commandline '\fileclstr\Websites\WebsiteName\API\DistributedServices.WebsiteName.exe ' at stage 'PostStartCheck', ErrorCode = '0x8027025b', assigned port 38520, retryCounter '1'."
Here is the web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<httpErrors errorMode="DetailedLocalOnly" existingResponse="PassThrough">
<clear />
</httpErrors>
<aspNetCore processPath=".\DistributedServices.WebSiteName.exe" arguments="" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Thank you in advance for any suggestions.
Asp.net Core 2.2, kestrel out of process, IIS10, Windows Server 2016.

This has taken many days, but I've finally got there.
The user had permissions on \\fileclstr\Websites\WebsiteName\ but this seemingly was not enough, and giving permissions to \\fileclstr\Websites\ allowed this to run in IIS out-of-process mode .NET Core targeting the full framework.
Thank you for your comments.

Related

The Module DLL C:\Program Files\IIS\Asp.Net Core Module\V2\apnetcorev2.dll failed to load. The data is the error

I have recently update an aspnetcore project from .NET Core 2.1 to .NET 6.0.
Since the update, the application will not run in IIS 10.0.
When I attempt to run the application, the application pool exits, and I see the following error in the Event Viewer:
Log Name: Application
Source: Microsoft-Windows-IIS-W3SVC-WP
Date: 1/18/2023 10:37:14 AM
Event ID: 2280
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: MACHINENAME.dev.oati.local
Description:
The Module DLL C:\Program Files\IIS\Asp.Net Core Module\V2\apnetcorev2.dll failed to load. The data is the error.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-IIS-W3SVC-WP" Guid="{670080D9-742A-4187-8D16-41143D1290BD}" EventSourceName="W3SVC-WP" />
<EventID Qualifiers="49152">2280</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2023-01-18T16:37:14.436510400Z" />
<EventRecordID>368815</EventRecordID>
<Correlation />
<Execution ProcessID="0" ThreadID="0" />
<Channel>Application</Channel>
<Computer>MACHINENAME.dev.oati.local</Computer>
<Security />
</System>
<EventData>
<Data Name="ModuleDll">C:\Program Files\IIS\Asp.Net Core Module\V2\apnetcorev2.dll</Data>
<Binary>7E000000</Binary>
</EventData>
</Event>
I have installed the relevant Windows Hosting Bundle:
I have installed the relevant Microsoft Visual C++ Redistributable:
I'm not sure what to check next. I have gone through multiple similar stackoverflow questions, as well as the aspnetcore github issues list and have not gotten a good idea of what to look at next to debug the issue.
EDIT:
Here is the Jexus Manager output for the application --
So it says ASP.NET Core module version 2 is not installed properly.
It is not clear to me why that would be the case, or how to remedy it.

Issue with web.config in Web API

I'm working on my first real world .Net Core 3.1 Web API and I'm getting an error with the web.config file but don't know what's wrong.
I create the Web API locally and it tests out just fine. I published the project to a local folder and then copied it out to IIS on our STAGE server. When I open IIS and click on any of the icons for the project (in this case I clicked the Logging icon) and I get an error "There was an error while performing this operation" and the file name points to the web.config in my folder structure.
The web.config file is created automatically when I publish the project. Anyone see what the issue could be with the web.config that's causing the problem?
<?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=".\AvTechAPI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 24142d05-13a1-4655-b2b8-8f8456003615-->
Windows IIS
Solution: Install the hosting bundle.
Reason: Although the SDK normally contains the runtime, however, it seems the SDK installer is not registering the runtime correctly on the server.
Workaround (not recommended):
Change AspNetCoreModuleV2 to AspNetCoreModule inside web.config.
Azure platform hosting
Install the .NET Core runtime extension by selecting Extensions and then installing .NET Core Runtime.

Can't deploy MVC application to IIS - Is my web.config file to blame

I'm struggling to deploy any MVC application onto IIS in a windows 10 environment.
I always get an HTTP error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid. It goes on to suggest there is a problem reading the configuration file.
On a similar post on this site it was suggested that asp.net was not installed but I'm certain that I've done it. I've used the Aspnet_regiis.exe tool and followed the instruction on the link below.
http://www.jammer.biz/enable-asp-net-on-windows-10/
The webconfig file as it came out of visual studio 2017 when I published is as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\HelloWorld.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: e88818e3-e6fd-4105-94cc-5be77ed93582-->
I've not edited it since none of the tutorials I've followed it tell me to.
I've made sure that full access rights on the folder are granted.
Here is the error message as seen from in IIS.
Why is IIS struggling to read my config file?
Thanks in advance.
Ian
I had this same issue when trying to publish a .NetCore2.0 mvc app. The solution can be found here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.1&tabs=aspnetcore2x
In my case, I did not have the .NET Core Hosting Bundle installed.

IIS (There was an error while performing this operation)

I receive There was as error while performing this operation error referring to web.config. I follow below configuration:
OS is Windows server 2012 R2 with IIS version 8.5.
URL Rewrite 2.1 module is installed on the machine.
IIS_IUSRS has full access to the directory.
Application Initialization module is installed
.Net CLR Version v4.0.30319 and managed pipeline mode is integrated.
IIS configuration is as below:
Web config is as below:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MES.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: e8701310-485f-4f88-b7d0-1473d07238ac-->
browsing the page I receive below message:
However, when I remove
<aspNetCore processPath="dotnet" arguments=".\MES.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
from web.config I don't receive (There was as error while performing this operation) error but I get below error:
This error occurred for me when trying to double-click on the Logging module for any site with a bad Web.config.
"Bad" includes Web.configs that just have a module IIS doesn't understand - in my case, IIS 10 couldn't understand the <rewrite> tag, and exploded with this extremely confusing error.
You can verify this by just commenting out the contents of your Web.config. The error goes away - then just gradually reduce how much is being commented out until you find the culprit, and track down that solution.
Add <aspNetCore> back and also install ASP.NET Core module on this machine,
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/aspnet-core-module?tabs=aspnetcore2x
I also wrote a tool to better automate such detection,
https://www.jexusmanager.com/tutorials/oob-500.html
This error is typically caused by a reference inside the web.config which cannot be resolved by the dotNet runtime.
If you are using dotNet core, AND you installed the dotNet core hosting bundle BEFORE you configured your server to run IIS you may get this error.
To fix it in this case, you need to re-run the dotNet core hosting bundle installer AGAIN, in "repair mode"
As described in the box entitled "Important", here.
I had this problem with .NET Core 2.1.
I installed 2.1 SDK (v2.1.301) and as Microsoft says Hosting Bundle now installs with SDK, but in my case this did't work.
This problem disappeared only when I installed 2.1 Runtime (v2.1.1) for Hosting Bundle Installer.
Maybe you need to install URL Rewrite
I had same problem.

IIS HTTP Error 500: The requested Page cannot be accessed because related configuration data is invalid [duplicate]

This question already has answers here:
MVC 6 Hosted on IIS HTTP Error 500.19
(3 answers)
Closed 6 years ago.
I have successfully published an ASP.NET Core website on IIS (version 10) on my local machine (Windows 10) and browsed it.
However, when I deploy it on IIS on another PC (using same versions), it gives HTTP Error 500.19:
I am using the same Web.config and IIS_IUSRS has permissions on both the virtual directory and config file. I also added the permission for the app pool `IIS AppPool/MyPool' to the virtual directory. Here is the web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\IdentityServer.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
What is problem?
It was missing the NET Core Windows Server Hosting bundle, I have realized that from the web.config "AspNetCoreModule".
You can find the link here
Can you try giving access to IIS Application pool user to the website directory, sometime if the files are readonly or if the IIS App pool user permissions are not there , this error might popup.

Resources