Publish asp.net 5.0 project to IIS fails with: The runtime was not packaged with the application - iis

I created a ASP.NET 5.0 Website Project.
I published the project to a folder on my pc.
I created in IIS a website pointing to the physical folder: wwwroot
When I go in IIS to "Browse website" and the Browser opens on localhost I see this error:
Unable to find the runtime directory 'C:\TGB.Published\TGB.Backend\wwwroot\..\approot\runtimes\dnx-coreclr-win-x64.1.0.0-beta5'.
Possible causes:
1. The runtime was not packaged with the application.
2. The packaged runtime architecture is different from the application pool architecture.
When I look in the published folder approot\runtimes there is the folder dnx-clr-win-x86.1.0.0-beta5 with content.
But I am confused why approot is mentioned under the wwwroot? As you see on my screenshot they are both on the same hierarchy. Why does it look for approot under wwwroot?
My Application Pool for the created Website in IIS is .NET 4.0.

I encountered this same error. For me the issue was with the Target DNX Version. I had the default option selected x86 and changing it to x64 solved it!
Check your application pool in IIS. If it does not have 32-Bit enabled then you need to publish in 64-Bit.

Related

How to host a asp.net core MVC app in IIS?

I am familiar with .Net in general but new to ASP.Net Core. I just had my first "self-hosted" ASP.Net Core MVC app running (created using templet and runs under Kestrel by default) . What I would like to do now it to host it in-process with IIS. But what I am struggling with is that I couldn't seem to find a clear and detailed instruction/document about what I need to do to get it to work. I have tried various configuration changes on my own but nothing works so far. I am running .Net Core 3.1 and using VS.Net 2019 on my Windows 10 environment. If someone could point me to the right direction it would be highly appreciated.
As far as I know, if you want to host the asp.net core application on the IIS. You should make sure you have installed the right hosting bundle.
Notice: No matter you use in-process or out-of-process, you all need install the IIS hosting bundle.
More details about how to install it, you could refer to this link.
After install the link, you could check your IIS module to make sure you have installed the right asp.net core module.
Then you could use VS to publish the application to right folder and create the IIS web site as below:
Create IIS website:

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.

ajaxcontroltoolkit missed when trying to republish published files on another machine or my local IIS

I have a published web application on specific server. I want to run the same application on another IIS server, but i get this error
Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.
Exception is here
Installing Report Viewer fixed it.
The problem was that my web.config was targeting .NET 2.0 and has some configuration related to .NET 2.0. I've updated the solution projects to target .NET 4.0 which need the report viewer dll in GAC folder or something global and that's what report viewer installer will do.

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.

Orchard CMS 1.4 - Install package failed

I am unable to install modules in Orchard 1.4.
I get:
Package installation failed: There was an error installing the requested package. This can happen if the server does not have write access to the '~/Modules' or '~/Themes' folder of the web site. If the site is running in shared hosted environement, adding write access to these folders sometimes needs to be done manually through the Hoster control panel. Once Themes and Modules have been installed, it is recommended to remove write access to these folders.
The IIS_IUSRS user have full permissions on App_data, Themes, and Modules.
Server is running Windows Server 2008, IIS 7.5.
The application pool is running .NET Framework 4.0, Integrated Pipeline Mode, and ApplicationPoolIdentity
I turned CustomErrors to Off in Web.Config, but i am not getting a stack trace or anything specific i can use to find the cause.
Any ideas?
Change the gallery feed URL to http://packages.orchardproject.net/FeedService.svc/

Resources