My first stab at trying to implement an ASP.NET Core Application to Hosted IIS Server.
I believe I could a malformed XML aspNetCore Attribute of the web.config
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
%LAUNCHER_PATH% is a placeholder.
based on this information
I changed the processPath="dotnet" and arguments=".\WebDevX1.dll" however running with that produces 502.5 Error. Running with just placeholders works fine. It was my understanding that I need to change those placeholders in order to publish to the Hosted Server.
Whether I modify the placeholders in those 2 attributes or not, the web.config aspNetCore Attribute still shows an error
When I run locally from Visual Studio, the web.config reverts back to the placeholders:
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"
ASP.NET Core 1.0.0 is installed locally
And my Host indicates they support .NET Core defaultly.
If someone has any insight as to what I'm missing I would really appreciate it.
You should have the publish-iis tool configured to run as a post-publish script. This tool replaces LAUNCHER_PATH and LAUNCHER_ARGS. You can find more details about this in my post about running ASP.Net Core applications with IIS.
After project.json to .csproj transition the publish-iis tool was converted to an MSBuild task (the TransformWebConfig task)
Related
I created a .Net Core 3.1 MVC application that is using induvial user accounts as authentication. I deployed the site to IIS, which works. However when I tried to log in with an account I know that works, the login does not succeed, and I am directed back the default route of the application. No error messages or log entries that I can find. The application pool is set up for non managed code, and is running under an account that has dbo rights to the database. Any thoughts as to what the issue might be?
http://localhost:44360/ running on server on Visual Studio 2022
http://localhost:2710/ running on server on IIS
http:// domain . com not working
It is difficult for everyone to help you without error messages. Have you tried swapping to a development environment to see the details of the error?
Locate the Web.config file and adjust it to set the ASPNETCORE_ENVIRONMENT environment variable as follows:
<aspNetCore processPath="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
This method worked for me to find the error, you can try it.
This field already exists in the web.config file.
It gives a warning when the user is wrong, but when we enter the correct user information, it does not create cookies or sessions and does not fall into any errors.
Recently I have had this problem that comes up often but I don't understand the reason for it.
With IIS I have my web site with my api and when I call them I get an answer but I added an application to my web site and this one sends me this error.
My api are in: C:\inetpub\wwroot\V4_1\
And the Xbap application can be found in: C:\Content\AppliWindows\Xbap\
Some of the servers I use with the same files don't have this problem.
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=".\Spec.Locbus.V4.Services.FrontEnd.exe" arguments="" requestTimeout="00:20:00" stdoutLogEnabled="false" forwardWindowsAuthToken="false" stdoutLogFile=".\logs\stdout">
<environmentVariables />
</aspNetCore>
</system.webServer>
</configuration>
<!--ProjectGuid: 821a3cf1-7c3b-4e36-8868-69fd8b417331-->
In Windows event log I get this error but it doesn't give me any more information:
Application '/LM/W3SVC/2/ROOT/content' with physical root
'C:\content' failed to start process with commandline
'.\Spec.Locbus.V4.Services.FrontEnd.exe ' with multiple retries.
Failed to bind to port '7993'. First 30KB characters of captured
stdout and stderr logs from multiple retries:
I know I get the same error when I try to call my api and I didn't install net.core2.2.8 but I installed it correctly and my api works.
The server I'm on is running Windows2019.
Asp.NET diagnostics seems to be good except for 2.2.8 at end of life :
System Time: 17/11/2020 15:57:29
Processor Architecture: AMD64
OS: Microsoft Windows NT 10.0.17763.0
Server Type: IIS
Scan 32 installed module(s).
ASP.NET Core module version 2 is installed for .NET Core 2.2 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (13.1.20295.10).
Scan 45 registered handler(s).
Found a valid ASP.NET Core handler as { Name: aspNetCore, Path: *, State: Enabled, Module: AspNetCoreModuleV2, Entry Type: Local }.
Visual C++ runtime is detected (expected: 14.0, detected: 14.28.29325.2 built by: vcwrkspc): C:\Windows\system32\msvcp140.dll.
The application pool 'LocbusV4' is used.
Pool identity is IIS AppPool\LocbusV4
Please ensure pool identity has read access to the content folder C:\inetpub\wwwroot\V4_1.
Pool bitness is 64 bit
Scan aspNetCore section.
"processPath": .\Spec.Locbus.V4.Services.FrontEnd.exe.
"arguments": .
"hostingModel": .
"runtimeTarget": .NETCoreApp,Version=v2.2/win-x64.
Runtime is Microsoft.AspNetCore.All/2.2.8.
.NET Core version 2.2.8 is end-of-life. Please upgrade to a supported version.
Runtime 2.2.8 requires ASP.NET Core module version 12.2.19109.5. Installed version 13.1.20295.10 might not be compatible.
Please refer to pages such as https://dotnet.microsoft.com/download/dotnet-core/3.1 to verify that ASP.NET Core version 13.1.20295.10 matches the runtime of the web app.
Has anyone ever had this problem and has a solution?
Thank you in advance.
I finally succeeded in creating a second site by creating the sub-application in this one and with URL rewriting redirecting the calls intended for the application from site 1 to the site of the app.
I created a .net core api (version 2.2.0) and I'm getting the following error when I try to run on IIS.
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
I verified my web config and it appears to have correct set of values.Enabled logging and log file comes as empty.
Event log shows the following error.
I installed hosting bundle and checked still getting same error. Also tried giving permission to IIS_IUSRS to the output folder. It didn't make any difference. Having said that error code "'0x80004005' " suggests a permission error. Still couldn't figure it out. Appreciate any help !
Web config
<?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=".\MyApi.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>`enter code here`
<!--ProjectGuid: 4d7644bb-9348-46f9-8397-95f01e03d599-->
Make sure you publish the site properly in iis. Your site root folder has enough permission to access it by iis. assign the iis_iusrs and iusr permission to the site folder. your application pool identity is set application pool identity or local system. anonymous authentication is enabled. and you installed the iis asp.net feature. make sure your site binding is correct and the application pool is using correct .net version and running under integrated application pool.
The reason behind the error message
The HTTP Error 502.5 - Bad Gateway and HTTP Error 502.5 - Process
Failure error messages occur in ASP.NET Core when IIS fails to execute
the dotnet process.
.NET Core Runtime is not installed
web.config file has not been transformed
To resolve this issue you could refer one the below-suggested way:
Install the .NET Core Runtime
The most common reason for this to occur is when you haven't installed the .NET Core runtime on the server.
You can download the latest .NET Core runtime from Microsoft's .NET download page.
After installing Bundle stop iis and start again.
Publish a Self-Contained Deployment
If you don't want to install the .NET Core Runtime. An alternative for .NET Core web applications is to publish them in the Self-Contained deployment mode, which includes the required .NET Runtime files alongside your application.
If you go with this option, you'll also need to choose a target runtime: win-x86, win-x64, osx-x64, or linux-x64. Because self-contained deployments are not portable.
Transform your web.config file
Another reason for this error to occur is when you deploy an untransformed web.config file.
This is likely to be your issue if you had a previously working web application and merely deployed a new version of it.
In ASP.NET Core applications, the web.config file contains a handler that directs requests to the AspNetCoreModule and an aspNetCore element that defines and configures the ASP.NET Core process to execute your web application.
Here is a minimal web.config file for an ASP.NET Core application:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
The issue is The untransformed web.config contains the variables %LAUNCHER_PATH% and %LAUNCHER_ARGS% rather than the correct paths. When IIS tries to run ASP.NET Core, it uses %LAUNCHER_PATH% and %LAUNCHER_ARGS% rather than the correct path and arguments.
To fix the HTTP Error 502.5 in ASP.NET Core, you need to transform the web.config and replace the untransformed web.config file on the IIS web server.
steps to transform web.config file:
This transformation takes place when you choose to publish your web application. The transformed web.config ends up in the published output folder. Therefore, you simply need to publish your web application and copy the resulting web.config file onto the server.
In a transformed web.config file, the aspNetCore element will look something like this:
<aspNetCore processPath="dotnet" arguments=".\MyApplication.dll" stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
%LAUNCHER_PATH% has been replaced by dotnet and %LAUNCHER_ARGS% has been replaced by the path to the main web application dll .\MyApplication.dll.
links:
Publish an ASP.NET Core app to IIS
I've made my first proof of concept ASP.NET Core application, I have 5 appsettings files:
appsettings.json
appsettings.Development.json
appsettings.Test.json
appsettings.Staging.json
appsettings.Production.json
I'm running the app in IIS so I actually have web.config files so that I can set the ASPNETCORE_ENVIRONMENT environment variable on a per application basis:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<aspNetCore processPath="dotnet" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development"></environmentVariable>
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
I have 4 web.config transforms so I can publish from Visual studio, and it will set the correct environment variable value for each environment.
When I publish to each environment though it publishes all the appsettings files. Is it possible to get it to publish on the root appsettings.json and the applicable environment specific one, but omit the others?
No, it's not possible. ASP.NET Core is not like ASP.NET. In ASP.NET, you literally published for the environment; if you wanted to switch to a different environment, you'd need to republish. ASP.NET Core is published for all environments. The same published app can be picked up and moved to any environment, without change. The actual environment is generally externalized, such as via and environment variable, and can be changed on a whim, without requiring new code to be deployed. This is actually a feature of ASP.NET Core.
Now, the way you're handling the environment variable does somewhat make it dependent on the publish, but that's just modifying the web.config, which itself only has meaning when deploying to IIS. ASP.NET Core itself doesn't care about or use web.config, and honestly doesn't even care about or use release configurations.
I have an ASP .Net Core 2.1 Web API which I've deployed to a new server we recently purchased (running Windows Server 2016 Standard). The API works perfectly on both my development PC and our old server (running Windows Server 2012 R2). But on this new server, I get this error:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
I remember a year ago also struggling a lot trying to get it to run on our old server. I did eventually get it to work, but I can't remember what I did! Is there any way to get more information on this error? I've checked the Windows Event Viewer on the new server and there is nothing there. Also, although I've got stdoutLogEnabled="true" in my web.config, it's not generating the log - and I've created the \logs\stdout path so the folders do exist...
I've also got app.UseDeveloperExceptionPage(); in my Startup.cs, but I'm not getting any more info that a simple 500 internal server error.
This is what my web.config looks like:
<?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=".\PropWorx.API.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: cfa62a1f-c5f6-43f8-bcbe-04068e40b803-->
I've also got the Microsoft .NET Core 2.1.1 - Windows Server Hosting installed and the Microsoft .NET Core Runtime - 2.1.1 installed (both x86 and x64).
Like I said it works on my development PC and on our old server, so it must be a configuration issue on the new server. Is there a way I can get more detailed error information other than just 500 Internal Server Error?
I had an outdated version of the .NET Core Windows Server Hosting bundle. I had version 2.1.1 installed. I removed it, and installed version 2.1.4 and now it works.
Various reasons can cause this issue.
if this is happening only in the browser (working with curl or postman), it can be a pre-flight request error, then you will need to modify UrlScan.ini (I assume this didn't changed on Windows 2016) at the following path (C:\Windows\System32\inetsrv\urlscan), add OPTIONS to [AllowVerbs].
if not, make sure you followed the steps provided in Microsoft documentation:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1&tabs=aspnetcore2x
You may need to install Visual C++ 2015 Redistributable on the server
To get logs, change "IncludeScopes": true, in your appsettings.json logging section, check also the event viewer.