Restarting an asp.net core app with IIS doesnt actually restart the app properly as program.cs doesnt execute - asp.net-core

I have deployed an asp.net core web app to an AWS Server running windows and IIS from azure devops. All the app code has updated, the dlls etc had updated but the new code that kickstarts serilog doesnt run.
This is because program.cs/startup.cs have not executed, it's as if the app updated but kept running withoout restarting.
Restarting the app in IIS or doing a full IIS reset, or restarting the IIS app pool does nothing. The app is running on port 80.
If I open powershell and type "dotnet myapp.dll" then the logs appear! because program.cs executed but that starts another instance on a different port and is nothing to do with IIS.
How do you properly restart a .net core app with IIS that actually makes it start up again?
Thanks

This is all because IIS didnt have permissions to write to the log folder.. lol. All ok now.

Related

Will publishing code to production IIS server interfere with running http requests?

I would like to ask if it is save to publish .net core web project to production IIS server directly through WebDeploy or Folder publish profile.
What about already running http requests ? Would it be better to stop the IIS website first, update codes and start website again ? But I don't know if stopping the IIS website will wait for running http requests or stops them by force. Does the publish profile handle this by default (for example it happens often with folder publish profile that files are being in use by IIS process and the publish operation fails) ?
What is your publishing process, do you stop the website instance ?
The configuration file will be saved when directly publishing the .net core project to IIS.
When publishing a .net core application, the web is not running in iis, but as a separate out-of-process console application, using Kestrel components. AspNetCoreModule is hooked to the IIS pipeline early in the request cycle, redirects all traffic to the following Core application, and all requests are forwarded to the Core process.
Requests come in from the Web and int the kernel mode http.sys driver which routes into IIS on the primary port (80) or SSL port (443). The request is then forwarded to your ASP.NET Core application on the HTTP port configured for your application which is not port 80/443. In essence, IIS acts a reverse proxy simply forwarding requests to your ASP.NET Core Web running the Kestrel Web server on a different port.
So I suggest you stop the website while publishing and restart it then. Files in the deployment folder are locked when the app is running. Locked files can't be overwritten during deployment. I recommend that you take the original application offline when you publish a new web, which is also recommended by Microsoft. More details can refer to following documents。
Taking an Application Offline before Publishing.
Locked deployment files

IIS, application pool stop Automatically

I am running WCF services on IIS 7.5 with .NET framework version 4.5 and it is in integrated mode. Whenever I deploy new code on IIS, it causes application pool to crash resulting in 503 error. I tried to dig into code but I am not able to figure out the root cause of the problem because of the large code base. I have ensured that it is not because of any server or IIS setting (as reverting the build makes IIS normal). I have also looked into event logs but not able to find anything, I am already logging application error but nothing is helping. Is there anyway I can trap the event or error just before crashing pool as I am running it integrated mode? Any help will be appreciated.

.NET Core Web App Restarting

I have a .NET core web app (console) hosted in IIS on a Windows machine. In the ConfigureServices method in Startup.cs I have a line of code which sends me an email so that I know when the service is restarted. When a new release is being deployed, I get that email, understandably. But I also receive that email at random times when there was no apparent restart of the machine, the app, or of any IIS component. Would there be any other thing which would cause it to restart? I'm not sure why this is happening.
Thanks,
IIS has a lot of settings for AppPool reset, like e.g. at given time, etc. You can check the advanced settings of your application pool that is set up to run your program and see if there is anything suspicious. It might be some inactivity timeout e.g.

Unable to Create the Web site 'http://localhost/WindowsService'. The Web server 'http://localhost' could not be found

I am working on a Windows Service and whenever I try to publish it, the error is thrown. I have already installed the service through installutil. I would like to test the module I've added before I commit.
It appears IIS was turned off in Windows features so I just turned it on (opted in IIS).

No intropage in a Managed Windows Service

I have to do some maintenance on a WCF service that is hosted in a managed windows service.
In the old deployed version I can enter: http://localhost:9091. It shows a page with info about the hosted WCF service (with a C# and VB example).
When I get the sources from TFS and reinstall with the MSI, the same http://localhost:9091 gives a 404.
What could be wrong ?
Could be lots of things. Try these for a start:
Installed msi on wrong port
web site / app pool not runnig
the configuration in web.config does not match the new location
Web site not marked as asp.net 2.0
IIS not configured to recognise svc files
The last 3 are the most probable. Check the event log for more details.
Here are a few more based on the comment:
is the service started
is the port blocked on the new machine
the configuration in web.config does not match the new location
Perhaps that port is meant to be the port of the ASP.NET Development Server. Is the service started? Open the solution in Visual Studio, right-click the service and choose "View in browser". That will have the side-effect of starting the service.