IIS + ASP.NET Core 6 + Hosting Pack resulting in default document/directory listing error - asp.net-core

I'm attempting to get IIS to serve our ASP.NET 6 web application, but every time it complains of needing a default document. If I run the exe (kestrel) one it will serve it, but we want it to be hosted by IIS with the other components of the site.
I installed the 6.0.10 runtime w/ hosting package and these are the results when listing runtimes:
When looking at the site modules, I think it should have what is needed (think the AspNetCoreModuleV2 one handles the compiled routing scenario?):
Have rebooted the server and the app pool specifically, set to No Managed Code, and whenever I attempt to load the page at the localhost level, I get:
The views are compiled so I don't think I even need IIS to open views locally in any capacity.

Everything you've posted ticks off the major deployment steps for hosting a .NET 6 project on IIS:
Installed the .NET Core 6.0 Runtime Windows Hosting Bundle
Set up the IIS app pool with "No Managed Code"
Rebooted the server: "Have you turned it off and on again?"
After our exchange in the comments, the only thing that appeared to be missing is to use the .NET publish command; not the build command.
When deploying to IIS, you'll want to run the dotnet publish command and then deploy those artifacts to your IIS server. From the docs:
The dotnet publish command's output is ready for deployment to a hosting system (for example, a server, PC, Mac, laptop) for execution. It's the only officially supported way to prepare the application for deployment. Depending on the type of deployment that the project specifies, the hosting system may or may not have the .NET shared runtime installed on it.
You also may want to review: Publish .NET apps with the .NET CLI.

Related

Deploy website to IIS from linux build agent

Problem description
I have a jenkins master that uses a linux build agent to build my ASP.NET Core websites using official MS linux docker containers.
I previously used a windows VM with the necessary tooling installed to build these projects and used MSDeploy.exe to deploy the sites to an IIS webserver. For this deployment I created a web package.
In my linux docker container I obviously can't use MSDeploy.exe.
Question
How can I savely deploy an ASP.NET Core website to an IIS webserver from a linux docker container?
MSDeploy.exe connects to the IIS using a local IIS Users credentials, shutsdown the app, replaces all files that are also present in the new package, so it not just replaces the files but also does some safety settings around the actual replacement.
Misc
I've found this question here, but unfortunately no real answer was found there.
Thanks in advance

ASP.Net Core API giving a 503 error from SSIS

I can't get my IIS site to run and I've tried most of the solutions I've seen. I started with a clean IIS server for testing this. If I try to access via the DNS name I get a 503. If instead I get on the webserver and run dotnet path\to\app.dll it starts without issue, and I can then curl localhost:5000/weatherforecast and get back the default JSON. So the app itself is clearly fine and working, it's something in the IIS config. Here's what I did:
Installed the .NET Core Hosting Bundle on my Windows Server 2019 system, then rebooted.
Ran Computer Management and in System Tools -> Local Users and Group -> Groups I added the domain account to both Users and IIS_IUSRS groups.
In IIS Manager I created a new site and set the binding to my DNS name on port 80.
Set the application pool for that new site to No Managed Code for the CLR version and set the identity to the domain account.
Created a default VS 2019 ASP.NET Core API, set the target framework to .NET 5.0
Published, via a Folder Profile, with a target framework of net5.0 and a runtime of win-x64.
Restarted the IIS site then went to http://my.domain.name/weatherforecast and got a 503.
I'm not even remotely close to being an IIS administrator, so at this point I don't know how to further debug the issue.

Hotswap DLL issue to update ASP.NET Zero dotnet core based webapp using Azure DevOps CD

We are building a webapp for our clients using ASP.NETZero template built on dotnet core 3.1.x
I am trying to create release pipeline in Azure DevOps and facing issues while publishing the changes of build pipeline to IIS similar way I did for traditional MVC5 or MVC6 .NET Framework based webapps.
The self-hosted devops agent is running on a different machine than production server where the webapp is published and the agent service account has access of the shared path of the \\server\inetpub-sharedhostingdir only.
Traditoinally, Copy Files task could replace app DLLs and all other files but in .NETCore there is an error like below:
Then I found out that this is because of changes how .NET Core 3.1.x hosting works.
I also tried to use 'OutOfProcess' in the web.config in the webapp but still getting same error and then I found this SO post and DLL hotswap info given by #MindingData.
So, my current bat to overcome this issue is using remote powershell in CD; I can stop the webapp and publish the new artifact. But there is cost for this step, I have to stop the site and replace all the DLLs which may roughly takes 30 seconds.
The remote Azure DevOps agent does not have access to do so right now and yet we have to add firewall exceptions to do so.
I am wondering if there is any other efficient alternative to publish .NETCore 3.1.x webapp using AzureDevOps agent running on a remote server? (as access of production server is restricted and we cannot deploy the azure agent on production machine.)
Because of these issues currently I need to move all the DLLs in 'backup' directory manually to make the hosting directory empty and then if I run the pipeline of first image, the 'Copy Files To' runs successfully and publishes the app well.
Any suggestions for improving the CD in current environment?
You may try using 'app_offline.htm' file for graceful shutdown of your running application and after deployment you can easily remove that file using powershell command task.
This approach should work as you have access of the deployment directory of the remote server. Steps are mentioned on the SO post.

How publish ASP.NET Core to a server without stop iis (error : The process cannot access the file because it is being used by another process)

When we publish our ASP.NET Core application and upload to the server, we get an error:
The process cannot access the file because it is being used by another process.
And when stop iis not error. How to upload without stopping IIS?
If you use web deploy to push to an IIS you own (a machine located in your datacenter) you can try to recycle the AppPool used by the web application you are trying to redeploy.
Go to your IIS Management Console
Right click the AppPool in question
Choose the recycle option
Be aware that this would also 'restart' all other apps which are associated to this AppPool.
This 'should' work in most cases.
If you deploy to Azure you might consider using either a Linux App Service or some Docker deployment mechanism altogether. You cannot use the In-Process IIS ASP.NET Core modules in these cases as far as I am aware of but at least deployments don't randomly fail.

How to start a released Asp.net Core project?

I'm an asp.net developer and recently trying to archive asp.net-core.
Since it's quite new, I would like to ask, how do you launch a asp.net-core project in a Windows machine?
For normal asp.net, my approach is publishing the project using Visual Studio, bring everything to a Windows machine, use IIS to create a website and point the directory to my physical file.
How about a website that created by asp.net-core?
Do I need to install asp.net-core in server machine? (i don't prefer this)
What should I do with the published file? There are two folders generated after publishing the project:
netcoreapp1.0
PublishOutput
Well, you still can use the file system mechanism to publish an ASP.NET Core project from Visual Studio. But VS uses the dotnet CLI under the hood to do the same stuff. Usually you configure your deployment depending upon your hosting environment such as Windows Server and Linux Server.
For Windows Server
You have to install ASP.NET Core Module in order to publish on IIS successfully. This will also install .NET Core SDK. You can than have the advantages of SSL Terminations and others provided by IIS on Windows Server.
For Linux
You have to use the .NET Core SDK here as well for a published app to acquire the .NET Core runtime (This is why you get those 2 folders). You use Nginx or HAProxy to get all SSL Terminations, Port-Forwarding etc.