I've studied the docs on how to do this but am still not understanding:
I've published my site from Visual Studio and can run the site from the command prompt using the command:
dotnet MyDotnetCoreApp.dll
That tells me the app started on http://localhost:5000 and I can browse to it just fine.
But how do I get IIS to start the app though so that I can go to the normal port 80? The web.config has the correct entry:
<aspNetCore processPath="dotnet" arguments=".\MyDotnetCoreApp.dll" .... />
All I get is 500 An error occurred while starting the application.
Must be missing some simple step. Thanks in advance.
Actually in your case you are not running using IIS, but using Kestrel HTTP Server.
You can read about Kestrel hosting configuration (and find how to change listening port) in this SO answer.
In case if you need to run under IIS (that is still publish option #1 on Windows, despite IIS is acting now merely as a reverse proxy and the application itself runs as a separate process using the Kestrel HTTP server), you may find Running ASP.Net Core applications with IIS article very useful, as it explains not just how to make ASP.NET Core works with IIS, but also "what’s really happening, why it’s happening and how the blocks fit together"
Related
I've gotten an Umbraco 9.0.1 instance up and running on a Linux server (Ubuntu 20.04). I'm using what appears to be the recommended approach of using Nginx as a reverse proxy to a Kestrel service
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-5.0
The issue I'm having is that any time I do a code update and deploy it to my Linux server, followed by a restart of the kestrel service, the site dies. I get a 502 bad gateway error. Reloading the daemon does nothing. The only thing I've found that seems to work is if I navigate to place in the filesystem where I've deployed the published application and run the command:
dotnet Umbraco.Nine.Linux.dll (Umbraco.Nine.Linux being the name of my project and the corresponding dll the result of the publish)
that command just hangs so I hit ctrl + C to stop it, but that brings the site back up.
Has anyone else experienced anything like this? If not, how are you handling Umbraco code deployments to a Linux server? I should add that if I use the default .net core website from Visual Studio, I don't have this issue. I deploy my code and restart the kestrel service and everything is beautiful, no site outage, changes show up. So maybe there is some Umbraco startup process that's making things die?
I've checked the logs for the kestrel service and they just indicate the service stops/restarts as expected. The logs in Nginx confuse me. They say something like
2021/09/27 15:35:08 [error] 81048#81048: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 184.67.248.194, server: <mysite.com>, request: "GET /umbraco/api/test/another HTTP/1.1", upstream: "http://127.0.0.1:2003/umbraco/api/test/another", ..."
EDIT:
I thought I should post some additional details, just in case it helps. For the publishing of the project, I am using Visual Studio built in publishing and choosing File System.
(Note I've tried the single file publish but I haven't even gotten that to run. I get an error indicating some library the project depends upon will not run in single file publish. Again, this seems Umbraco specific as I can get a default asp.net core site to publish just fine like this. I'm only adding this note in case it's relevant to something just being wrong with Umbraco 9 as we're still very early in the release.)
After that I just zip it up, upload it to the server, unzip it with commands like:
unzip -o website.zip -d <path/to/my/web/app/>
Then
sudo systemctl restart <my.kestrel.service>
That's when browsing the site yields the 502 Bad Gateway I described above. Any help on what I'm doing wrong would be greatly appreciated.
So, I solved this, sort of. I've abandoned the whole kestrel thing and I'm using a docker container to run the asp.net core application. I'm still hosting using nginx as a reverse proxy. The only difference is instead of having a systemd kestrel service listening on the specified port, it's a docker container doing it.
I posted details here: https://our.umbraco.com/forum/umbraco-9/107189-umbraco-nine-on-linux-server-site-dies-after-deploying-code-changes
Hopefully it helps someone else out!
I'm pretty excited because the whole thing is 'script'-able so I managed to automate it in an AWS CodePipeline.
I have MVC4 web application project in visual studio 2010. When I want to start it, I have the following error:
Unable to launch the IIS Express Web server: Port"80" is in use.
The problem came after changing the property "Use Local IIS Webserver"
http://blog.lextudio.com/2012/10/port-already-in-use-then-who-uses-it/
If you already have something monitoring port 80 (such as full IIS), then you cannot use another thing to monitor the same port.
Thus, if you do want to use IIS Express, make sure in Project Url: field you specify another port number other than 80.
In VS 2013:
Go to your Web Project Properties, Web Tab.
Select "IIS Express" from the dropdown.
Enter a project URL, such as http://localhost:64510/
If you have "Override application root URL" checked, uncheck it.
The port is probably in use. I usually end the iisexpress.exe. This works if for some reason the port is open and you want to close it.
CTRL+ALT+DEL -> Task Manager ->End process for iisexpress.exe
I just had this happen to me, and didn't understand why as everything had worked fine until restarting my machine. Seems that the full IIS service was running, but only within the manager had it been STOPPED, so when I restarted it turned back on.
FIX IT THIS WAY:
Open up the Internet Information Services (IIS) Manager (use search programs and files, too. See image)
Right click on localhost (top level, left pane), select STOP. Not called 'localhost'? This will probably be called your machine name, but if you hover over the top level on the left pane, you should see 'https://localhost/'. This is what you want. Right click and select STOP.
Now, this is assuming you only want to run IIS Express sites, as anything that required the full IIS won't be running. You should be good to go!
If IIS is running and you are using IIS Express you should stop IIS for it to work.
Such error can appear when YourApp.csproj file contains conflicted settings.
<!-- conflicted settings -->
<UseIISExpress>true</UseIISExpress>
...
<IISUrl>http://localhost/application/</IISUrl>
If you want to use IIS Express you should change IISUrl to http://localhost:11222/ or another free port.
<!-- settings for IIS Express -->
<UseIISExpress>true</UseIISExpress>
...
<IISUrl>http://localhost:11222/</IISUrl>
If you want to use IIS you should set UseIISExpress to false.
<!-- settings for IIS -->
<UseIISExpress>false</UseIISExpress>
...
<IISUrl>http://localhost/application/</IISUrl>
Another answer does mention this, however, if you're using IIS Express within Visual Studio AND have IIS enabled in Windows Features; It will be the "Default IIS Site" that is using port 80. Simple open IIS and stop the site running by right-clicking on the top node.
Sql Server could also be the culprit. I stopped Sql Server and it freed up the port.
http://localhost:72/Home/Support?_subject=&_category=&_reportedDateFrom=09%2F05%2F2013&_reportedDateTo=09%2F05%2F2013&_solvedDateFrom=&_solvedDateTo=&_status=
Above is the pre-setup IIS website .. the date filtering is not filtering correctly.
http://localhost:54550/Home/Support?_subject=&_category=&_reportedDateFrom=09%2F05%2F2013&_reportedDateTo=09%2F05%2F2013&_solvedDateFrom=&_solvedDateTo=&_status=
Above is the visual studio debug URL, just the port number is different and it's working perfectly.
I have no idea what is happening.
To debug this I would start with the following:
Do a clean and rebuild of your solution.
Make sure you don't have two copies of the application running.
Make sure the application is being hosted in IIS properly. (Does the app show up when you right click and browse the web site from the IIS manager)
Attach the debugger to the process running under IIS in order to inspect the query parameters.
This article is getting a bit old but it has the general procedure you need to follow to attach to IIS to inspect a process.
I hosted my asp.net mvc3 application on amazon ec2 cloud using windows server 2008 R2. The first time page loading is very slow. I decided to enable auto start on IIS 7.5.
I followed Scott's post.
http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx
I only have one web application hosted on this server, and this application got its own app pool, not shared with anything else.
this is all I did, add startMode="AlwaysRunning".
here's hte problem. I see performance gets a little bit better, but still about 4-5 seconds.
Is there way to verify if my auto-start setting acutally works?
If you have access to IIS Manager on the box, you can examine "Worker Processes" for the site. Otherwise, look for a process named w3wp.exe. If you only have one site, it should be the only process.
Try stopping the application and confirming the worker process has stopped. Now start the application without issuing a request. If the process is there, auto-start is working.
EDIT: Slides 11 and 12 from http://www.slideshare.net/brianritchie1/iis-alwayson-services may be helpful.
Setup: Windows Server 2008 R2, IIS 7.5
We currently have multiple ASP.NET applications hooked up to the "Default Web Site" site in IIS on a server.
Sites
Default Web Site
aspnet_client
Site_v1
Site_v2
Site_v3
I have recompiled the binary for the site, and copied over the files for "Site_v1", then done an IISRESET command.
My issue is that the web app does not actually reset. Our app logs initialization of certain core objects, and the logs do not show that the app is restarting.
Our current theory is that some user has a browser open to one of the default web sites, and that's preventing me from correctly resetting IIS.
Anyone seen anything like this?
Thanks in advance.
Note: I'm posting this to Stack Overflow and not Super User because this is a problem on a development server. I'd like to solve this as a developer correctly compiling an application, rather than as a sys admin changing server settings. Hope that makes sense.
UPDATE:
From Werner's suggestion in the comments, I deleted the temporary files for Site_v2, but could not delete them for Site_v1. Some process was locking the files. After resetting IIS, Site_v1 was working properly, but not Site_v2.
Superconfused!
MS have stopped support for the IISReset command, which means that your approach is OK, but will not work any more. It works for IIS6.0, but not 7.0 or 7.5.
Ref: http://technet.microsoft.com/en-au/library/dd364308%28v=ws.10%29.aspx
It can be done "by hand" using the GUI, but that is not scripted. I have the same issue, working on an alternative.