ASP.Net core 2.2 deployment issue in IIS - iis

I am new to .Net core environment and facing issue while deploying application into IIS.
After publishing code and deploying into IIS server(Version 7), I am able to start application from Kestrel by going into directory where application hosted and running below command.
c:\inetpub\demoapp\dotnet "My App.dll"
By running above command, Kestrel is running on http://localhost:5000 and I am able to browse from browser. I am using latest .Net Core version 2.2.
But when I am trying to execute URL from IIS hosted application, I am getting below error.
HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure
Below is the event log from windows application log.
Application '/LM/W3SVC/49/ROOT/demoapp' with physical root 'C:\inetpub\demoapp\' failed to start process with commandline 'dotnet .\MyApp Web.dll' with multiple retries. The last try of listening port is '2405'. See previous warnings for details.
Anyone having idea how to resolve it?

In my case, It was win-64 architect issue.
You can change or switch architect from win-64 to win-86 then publish and don't forget to change Enable 32-bit Applications in IIS manager:
Right-click on the Application Pool and select “Advanced Settings…”
or select the same from the Actions pane after selecting the
Application pool.
Change the “Enable 32-bit Applications” to True (if you want the
application pool to spawn in a 32-bit mode)
Click OK.
p.s.: Don't forget to delete existing published files.

Related

Running multiple ASP.NET Core 2.2 webapps side-by-side in IIS

I'm trying to run 2 ASP.NET Core 2.2 webapps side-by-side on IIS 10. I created CoreTestApp1 & CoreTestApp2 (default VS template, no added code), i.e. both set up for In-Process hosting.
After I restart my server (IIS Mgr), the first webapp that I open in a browser (e.g. CoreTestApp1) runs fine; if I open the second one (CoreTestApp2) I get an error "HTTP Error 500.0 - ANCM In-Process Handler Load Failure".
If I restart my server again and open CoreTestApp2 first, then that runs fine, but now CoreTestApp1 causes the same error.
I tried running 2 ASP.NET Framework apps side by side, and that works fine.
Judging by the info I found (e.g. https://learn.microsoft.com/en-us/dotnet/core/deploying/index), it seems I should be able to run multiple core apps side-by-side?
Is there some extra config stuff that I'm missing?
Not sure if this is relevant, but I used Visual Studio's publish (to folder) with these settings...
Configuration = Debug
Target Framework = netcoreapp2.2
Deployment mode = framework-dependent
Target runtime = portable
Thanks to Lex's suggestion and some more googling, I found the answer to my question here:
The ASP.NET Core module V2 running in InProcess mode has to run in its own dedicated Application Pool. According to the documentation you cannot run multiple sites or virtual directories (Web Applications) using the the ASP.NET Core Module in a single Application Pool. Make sure each ASP.NET Core app on IIS gets its own Application Pool.
Creating extra Application Pools and assigning each ASP.NET Core app its own solved my problem; instructions on how to create App Pools here.

ASP.NET Core 2.0 app targeting .NET 4.6.1 fails to host on IIS

The problem
IIS ASP.NET Core module is unable to start an ASP.NET Core 2.0 app.
Browser: HTTP Error 502.5 - Process Failure
Windows Event Log: Application ‘MACHINE/WEBROOT/APPHOST/AppSite’ with physical root ‘C:\inetpub\apps\AppFolder\’ failed to start process with commandline ‘C:\inetpub\apps\AppFolder\App.exe’, ErrorCode = ‘0x80004005: 1’.
ASP.NET Core Module Log: Log file is created but is empty.
The setup
App: ASP.NET Core 2.0 targeting .NET Framework 4.6.1.
Server: Windows Server 2012 R2 Standard 6.2.9200 with IIS 8.5.9600.
The story
We've created a blank MVC Web application using the default project templates provided in Visual Studio 2017.
The app is deployed following the official specification: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/.
The confusion arises mainly from these two points:
Running the app through command-line on Kestrel works.
Running a different app but targeting .NET Core 2.0 and publishing as framework-dependant works flawlessly on IIS.
But between these two apps: the codebase is the same, the IIS website and application pool is the same and we even emptied out the app directory and used the same one.
Due to these points the only difference seems to be the net461 app's executable file.
We do not have full control over the Windows Server where we're trying to deploy but we do have administrator accounts. The current assumption is that the issue lies within permissions - maybe AD group policies, antivirus blocking the file but we're still awaiting response from the client's sysadmins. Meanwhile we haven't been able to replicate the error code ‘0x80004005: 1’ while trying to setup these restrictions on our development machines.
Here's an incomplete list of ideas and points about the issue we've tried while problem solving:
The initial app (targeting net461) works flawlessly on IIS when
deployed to other servers (Windows 10 Enterprise, Windows Server 2012
R2 Datacenter).
Reinstalling different versions of ASP.NET Core/.NET Core: Runtime & Hosting Bundle.
Setting NTFS permissions to the dotnet folder.
Changing IIS application pool identity to an administrator account.
Restarting the server.
Going over local group and security policies.
Going over the antivirus settings and logs.
Trying to deploy on a brand new server (same OS, same bloat).
All ideas/comments are greatly appreciated. The more obscure the better.
EDIT:
Since this got flagged as a possible duplicate of ASP.NET Core 0x80004005 I need to specify why that is not a duplicate.
That referenced project is an older version of ASP.NET Core (last use
of project.json was in 2016)
That referenced project targets .NET Core and not .NET 4.6.1. It is mentioned here as well that targeting .NET Core works on IIS in regard to this issue.
Selected answer points out that they fixed it by:
Turns out that this was result of needing to install some windows
updates and this problem:
api-ms-win-crt-runtime-l1-1-0.dll is missing when opening Microsoft
Office file
Rather than install the version discussed in the above issue I whet
into Programs and Features and ran a repair on Microsoft Visual C++
2015 Redistributable.
but the installation of Microsoft Visual C++ 2015 Redistributable is one of the steps in the official setup guide and it is mentioned here as well that the official guide has been followed during the setup process.
We have gone over that post and tried to repair and reinstall the Microsoft Visual C++ 2015 Redistributable runtime components and this did not fix the issue.
If anyone stumbles upon this post in the future:
The problem was indeed in the server's antivirus. It wasn't directly blocking the app's executable but its call to a class library in the system folder. This termination did not raise any of the usual alarms.
The application "C:\inetpub\apps\AppFolder\App.exe" attempted to load the library "bcrypt.dll" by calling the function "LoadLibraryExW". The operation was blocked and the application terminated.
After switching the MVC blank app to a completely blank Hello-World app it ran successfully.

Page keeps loading forever

Im using IIS 8.5 on Windows Server 2012 R2 so I add my Web Api but when I try to view the site it stays in a loading state like this:
Do not show any message or error just stays loading, I think that i miss some configuration or feature in my IIS but I don't know which one.
Edit: I use .Net framework, it is a REST .net web api like this reference, the IIS have installed .Net versions 3.5 and 4.5, it's IIS not the express and the default IIS website runs fine.
I would really appreciate any help.
Try to reduce the timeout settings to a minimum level, say 10 seconds.
See if it throws a Timeout error.
Without much information from your side its hard to judge.
Perhaps it could be an external service you are trying to access(Web service) or a DB connection?
Please check if the application pool you assigned to your solutions runs under the correct version of .net framework and in integrated mode. I had similar issues when trying to run an mvc app in classic mode. Check this out.
EDIT 1 - Reconfiguring IIS
If problems persists then try the ASP.NET IIS Registration tool. Execute the followig command as administrator:
aspnet_regiis -i
At the end of this post the different locations for aspnet_regiis are described. You should select a .NET Framework version corresponding to that of your project, run aspnet_regiis and assign the proper application pool to your app.

Unable to see "Management Service" in IIS 10 (Windows 10)

I have windows 10 (pro) and IIS 10 installed on Server A. I was trying to publish a Web API from Visual Studio 2015 on Machine B to Server A, but I get the following error.
web deployment task failed. (Could not connect to the remote computer ("172.26.50.17") . On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started.
I understood from googling that the web server need to have Management Service installed and running. I have installed web platform installed and I can see that the "Web depoy 3.6 without bundled SQL support(latest)" component installed.
But I still do not see management service icon under "management" section on IIS. Could anyone please help me understand this?
I solved it by installing the Web Platform Installer (Web PI).
Then you can add a lot of tools using this Web PI. One of those tools is Management Service which can be enabled via Web PI.
If you do that and still cannot see the Management Service, try closing and opening the IIS Manager again.
UPDATE:
For Windows 10 and later, see the #RBT comment below.

Can host ASP.NET Core site through console but not through IIS

Solution and server configuration:
I have developed a fairly simple ASP.NET Core application. It consists of a core project file, created and built in Visual Studio 2017. The target framework is .NETCoreApp 1.1 and Platform target is x64.
It also contains two class library projects with target frameworks .NETStandard 1.4 and Platform target x64.
Due to a bug in VS2017's Web Deploy, I am publishing to file system, then copying the contents of PublishOutput to my IIS application's directory using FTP.
My server is Windows Server 2012 R2 with all relevant service packs and updates. DotNet Core runtimes have been installed.
The issue:
When I navigate to my site's URL in the browser, I encounter a bland HTML page which indicates the following:
HTTP Error 502.5 - Process Failure
Common causes of this issue: (lists things)
Troubleshooting steps: (lists things)
For more information visit http://go.microsoft.com/fwlink/?linkid=808681
Steps taken to resolve:
Needless to say, I've followed the instructions to resolve. The link given shows my error under the heading of Platform conflicts with RID.
The Event Viewer has an Error entry with the following:
Application 'MACHINE/WEBROOT/APPHOST/MY SITE' with physical root 'C:\inetpub\wwwroot\mysite\' failed to start process with commandline "dotnet" .\MySite.dll', ErrorCode = '0x80070002 : 0.
By opening an instance of cmd.exe at my site's folder, I can execute dotnet mysite.dll and it runs, hosting on http://localhost:5000. I can navigate to the site in a browser, as expected.
My Program.cs is as follows:
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
My Startup.cs is mostly uninteresting. Excepting some service definitions, my pipeline is:
app.UseCookieAuthentication();
app.UseRedditMiddleware(); // authentication middleware, custom
app.UseMvc();
app.UseStaticFiles();
Either the system wide %PATH% to the dotnet folder is not set (IIS runs as a different user) or you did not restart your server after installing ASP.Net Core Server bundle. You can find more some troubleshooting steps in my post about running ASP.NET Core applications with IIS.

Resources