Docker-Compose Connection Refused with ASP-NET Core 5 - c#

I've been using ASP.NET Core 5.0 for a project and running it via docker-compose inside VS2017 Community.
Previously when I ran the project it would connect to a port automatically published by Visual Studio and load the web application (see image 1). However, similarly to another project, it simply refuses connection when debugging starts (see image 2).
Even when manually publishing the ports via the ports: portion of the docker-compose.yml file it still refuses connection.
After trying to find a solution to no avail, I've turned to asking here. I've tried all of the following:
Restarting Visual Studio
Deleting the .vs folder and restarting.
Restarting computer.
Exposing ports 80 and 443 explicitly in docker-compose.yml
Checking out to previous, known working commits.
As mentioned before this behavior has also started occurring on a university assignment which is running ASP.NET Core 3.1, which I prefer to have working before it's due.

I did Clean/Purge Data on Docker Desktop for Windows, restarted and it seems to be working now. I really wish I knew what actually causes this problem so I can avoid in in the future....

Related

Razor pages always gives 404 unless using dotnet run

I have a razor pages project that until recently worked fine, and on a colleagues computer works fine. On mine however, when running from Visual Studio or publishing to Azure via Visual studio it returns 404 for every page. Everything works as expected if I bypass Visual Studio and use dotnet run instead. Interestingly, previous commits that worked fine for me also now have the same problem. Which leads me to think its something environmental, but I can't track the cause down.
I also faced the same issue .
Try to use dotnet build instead of dotnet run.
Also check you map the path in azure configuration for your application in the azure app service

After migration from .NET core 2.2 to .NET 5 the application won't start after deploying to azure app service - startup timeout

I am having the following problem. A while ago I migrated my project from .net core 2.2 to .net 5. Migration itself was no problem, locally everything worked almost out of the box. But then I was facing problems deploying the app into an azure app service. The app wouldn't start up. I was getting start up timeouts. After a while I solved the problem by switching the hosting model to outOfProcess
<PropertyGroup>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
Because of lack of time to thoroughly test the application, I had to stick with .net 2.2 until now.
Now that I migrated again, I am facing the same issue. Locally everything works just fine, but after deploying to the app service, the application won't start. But the hostingModel doesn't solve it this time.
I tried linux and windows app service, and I tried to deploy via our azure devops pipes as well as manually from VS. I tried to deploy into an existing app service, I tried to deploy into a new app service, created during the deployment process. None of it solves it.
When i look at the log stream, I see the following:
2022-02-10T09:13:55.360Z ERROR - Container webapp... for site t2bwebappdev did not start within expected time limit. Elapsed time = 230.2593377 sec
2022-02-10T09:13:55.368Z ERROR - Container webapp... didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
So I tried to solve this via PORTS and WEBSITES_PORT settings - but non of it seems to get it up and runnig.
Thanks in advance for any hints on how to solve this.
Update:
While I was playing around with the logs, I saw that the app was listening on port 5000. Seems with the Net5 upgrade the launchsettings.json is being ignored.
Then I just dockerized it from VS 2019, and in that container I can also not reach the app. So after all this, could it just be a port issue?
Try adding this line in your Program.cs class:
And make sure you expose ports in Dockerfile:
NOTE:
Everything depends on which port was exposed in Dockerfile.
Port that you have exposed should match with the port you will pass to UseUrls as an argument. Also, consider either http/https in accordance with the existence of the certificate.
I hope my answer was useful and helpful!

Why is IIS Express sending 426 Upgrade Required errors for requests to one my .Web projects?

I have an asp.net application. It has 7 .Web projects, each running on a different port.
I am able to access the APIs and web page for each .Web project except for one: DemandService.Web.
For this particular .Web project, I cannot receive any valid response. The response code is always HTTP 426 Upgrade Required, and this response is sent with the following Headers: server →WebSocket++/0.3.0-alpha4.
Further, this .Web project no longer appears in IIS Express list of running sites.
I have re-GETed my application and have restarted my computer. I verified that there are no pending changes in DemandService.Web that are not found in other .Web project. I am unsure what has changed that may cause this.
Any ideas? Can I reset my IIS Express configuration somehow?
EDIT
I uninstalled and reinstalled IIS Express 10.0. Now IIS Express indeed starts my .Web project and I can see it running. However, instead of using the port 9005 specified in the project properties, it runs the project on 44322 and is otherwise working.
Why is IIS Express switching the port on me? Seems like there is some conflict with port 9005 configuration. Is there a vhost directory I should re-configure?
Sure enough, the fact that the protocol being used on port 9005 was WebSockets was an indication that the response wasn't coming from IIS Express and therefore I could assume that it wasn't a project or IIS Express configuration problem.
Running netstat -a -b shows all the applications using a port on my computer. I examined which process was using port 9005 and the application was CiscoVideoGuardMonitor.exe.
This software is StreamingDRM software that comes with DirectTV player. I installed this last week to watch a basketball game.
Uninstalling this software gave me my port back, which allowed IISExpress to start my service properly, and now I am able to access my .Web project.

Visual Studio 2015 version 3 freezes on editing Roles in Azure project

I'll preface this with the fact that I'm very new to Visual Studio, so I am prepared to hear that my problem lies in something I haven't read yet.
I have a database first project in Visual Studio 2015 v.3 that I am attempting to publish to an existing Azure account and resource group.
I have successfully converted it to an Azure project via the menu options: Build > Publish to Microsoft Azure.
I can successfully build both the local and the Azure projects without error, but whenever I attempt to edit the Roles in the Azure project to add the Azure connection string as per the tutorial found here, the program hangs up irretrievably. This makes my twelfth attempt to edit the Roles.
It took Visual Studio five tries to publish to Microsoft Azure using the menu options above.
To fix this, I have tried all of the following:
Restarting my computer
Restarting my Azure connection
Restarting Visual Studio
Confirming Visual Studio's connection to the Azure account I want to publish to
Checking to be sure my Azure SDK (version 2.9.1) and Visual Studio (version 3) installations are the most recent versions and that the installation appears to be clean
Removing the Azure portion of the project, cleaning and rebuilding the local solution, and reattempting to publish to Azure
Cleaning and building both solutions before attempting to edit the Roles for the Azure portion of the solution
Confirming that the resource group I am attempting to publish to does exist at the specified connection string and contains the necessary resources (in this case, a server and an SQL database)
I am attempting to connect (for now) with HTTP and not HTTPS, as per other similar questions about Visual Studio 2015 freezing while publishing to Azure
Confirming that I am able to connect remotely to Azure via Visual Studio (this is probably a gimmie, but it doesn't hurt to be specific)
I also notice that when I attempt to browse the Azure features on the menu to the left of the Visual Studio window, Visual Studio freezes (particularly if I click on the links for Data Factory, Mobile Services, Service Bus, and Virtual Machine).
Server Explorer is showing that I am logged in to Azure with the account I'm attempting to publish to.
I can reach, read, and edit the local database files. I can also run the local project without error.
The application was configured to use an IIS Web Server and uses SQL Express. It froze repeatedly while attempting to change configurations from the IIS Express and LocalDB default to IIS Web and SQL Express.
I do have the application backed up locally as well as via a private GitHub repo just in case I manage to bork it permanently trying to do this.
I would very much appreciate the help.
edited to add: I'm currently running Windows 10.
edited again to add: The task manager shows the load to memory and CPU during the period when Visual Studio is frozen to be less than 15%, the majority of which is not Visual Studio. It shouldn't be a hardware issue, but I did try closing the majority of the background services that were non-essential just in case there was some sort of conflict occurring.
Making this an answer instead of a comment because while it may be a silly oversight, there's bound to be someone who would benefit from the answer.
The problem was that I was working from a local copy of a remote database. When it came time to push up to the remote, I deleted the local copy and data interface model, and reconstituted the model on the remote database, creating several connection strings in Web.config.
When I attempted from there to publish, Visual Studio read the connection strings in the Web.config for the project and attempted to hunt down the local and over-write the remote database.
Removing all other connection strings from the Web.config for the project removed many of the problems with freezing and hanging that I was experiencing (and made the project run faster by resolving the search for associated project resources.)
Lesson learned: make sure you clean your Web.config file before attempting to push to remote.

"Required permissions cannot be acquired" while debugging standalone application

I'm trying to debug a native application that uses some C# components but I'm getting a "Required permissions cannot be acquired" error when trying to start the application.
Now I did search StackOverflow and the net in general but all answers that I could find were related to ASP Web applications but the one I'm trying to debug is a standalone one.
Additional background: I'm using WinDbg to debug code that runs in a remote machine via remote terminal (in fact by using TWO remote connections since the machine in question is not reachable from my machine directly thanks to some stupid router configuration). The binaries are located on my computer and I access them via the auto drive mapping that RT does for me.
Now I did have similar issues in the past and I'm pretty sure that the code would run if I copy all the binaries to the target machine and start them from a local drive but this is something that I want to avoid.
NOTE: The code is targeting version 2.0 of the .Net Framework. The target machine does not have the configuration tool for .Net 2 installed and I gave up trying to install and make it run by hand to try to see if there is some "trust" setting that I can set to mke the code run..
Problem turned out to be a firewall issue and related to the fact that I could not reach the target machine (where the program was running) directly from my PC (where the executable files where located). I was connecting indirectly through another PC to the target machine and this was causing problems with the .Net security checks, after changing the switch/firewall so that I could connect directly I had no more problems.

Categories

Resources