ASP.NET Core Web Application console closes immediately - asp.net-core

I'm trying to run an ASP.NET Core Web Application using its console profile. The console opens and closes immediately so I get ERR_CONNECTION_REFUSED error in browser. Is it possible to find out why the console/host closes? There is nothing in event log and I've enabled stdout but it doesn't produce any output.

Try to start you app from already open console window.
Run cmd, navigate to your project folder and execute dotnet run.
Your app will start and terminate, but console window will remain open and you will see exception (if any) or other output that may help you.

Related

Visual Studio 2022 .NET 5+ API stops debugging on image upload

Whenever I start my .NET 5 API in debug mode and I try to upload an image with my browser, not associated in any way with the .NET project, VS 2022 stops the debug process.
For instance if I use https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_accept and upload an image with the input field , the debug process stops.
It also stops whenever I:
Try to log in using FB/Google login button anywhere
Using Brave (browser) have two separate browser profiles open and close one of them
Any ideas on what it might be? Or a way to search out a cause
Okay, I found the solution
In Visual Studio 2022 you need to uncheck: Tools -> Options -> Project and Solutions -> Web Projects: "Stop debugger when browser window is closed".
Apparently Visual studio treated every image upload or every browser that is closed as closing the debug browser window and stopping the process. Weird.

Locating CLI error logs when deploying an ASP.NET MVC5 app using web deploy fails

I am trying to deploy an ASP.NET MVC5 web app (web deploy deployment package) on my Windows Server using Command Prompt as I have done countless of times before with the same web app. When I try running the command
myproject.deploy.cmd /t
inside the correct folder the process starts but then abruptly stops and the CLI window closes.
Just before the window disappears I can see an error message in red, but I just do not have enough time to read what it says.
My question is where does one find the logs for commands that have failed? Alternatively is there a way to force the CLI to stay open in order to read the error displayed?
I managed to find the logs in the Event Viewer:
Event Viewer -> Applications and Services -> Microsoft -> Windows -> WebDeploy -> Errors

Web app not responding on localhost:5000 when run standalone

I have simple DotNet Core app that runs fine with dotnet run but when I do dotnet publish and then dotnet HelloWorld.dll (in the bin/Debug/netcoreapp1.1 directory; same with bin/Rebug/netcoreapp1.1), on my local machine, the command prompt says "Now listening on: http://localhost:5000" but the service is not responding when I navigate to that address with my browser. Are there any kind of logs to review?
I reproduce the same in Windows 10 and OSX 10.11, both with clean dotnet new -t web projects, without any modifications.
In Windows I ran netstat -noa | find "LISTENING" and can see port 5000 at the bottom of the list. But still no connection when I try.
Ideas?
The browser output is:
The localhost page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500"
I run .Net Core 1.1.0 - SDK 1.0.0 Preview 2.1-003177 on both the Windows and Mac machine.
Click on the ^ icon of your toolbar to see hidden icons. If IIS is running, you will be able to see each instance and the port that the instance is listening on
I got the same error. To diagnose the error, I started up the app not in IIS Express but in what I think is a self-hosted option that opens in a console window.
If you look through the log in the console window, you might see an error in that log.
Also, I've noticed that sometimes the browser window pops up and navigates to the URL before the host environment is ready to handle the request. All you have to do when you get this error is wait a second and refresh the page, and the host environment will be ready and the page will load.

Stepping through code from console application into wcf web service

I created a wcf service in a solution and a console project in the same solution
I hosted my wcf service in IIS and makes a call to the uri in console application
From my wcf application I did a right click on the project,selected debug and then
selected start new instance
I set breakpoints in my console application and in the first method that gets hit
in my student.svc.cs file
I went to windows explorer and double clicked my console application executable
I am able to step through from my student.svc.cs file but the breakpoint on my console
application does not get hit.
I want to be able to step through code from my console app then to the webservice
but this is not happening
Any ideas ?
You are not executing the "right" project (bin folder in this case). You can set the console app to start project and set the wcf service to start on debug (options), then you can step through from your console app to the service.

How do I start a console application in one project from a web form in another project?

I have a website created in VS 2010 with .NET 4.0. There are multiple projects in the solution. In one of the projects I have a form that gives a user the option to run a console application that is in another project of the solution. (called update.exe)
I have tried just using
process.start(filepath + "update.exe")
but it doesn't seem to run.
It finds the file but then finishes immediately. I tried adding Console.readKey() to the console application so it would stay open after being called, but it was to no avail.
On top of this, I know that the console app isn't running as I have logs set up throughout the console's code and it never even seems to kick off.
Should I be calling the console app differently? (note: I am writing in VB.net)
Thanks!
Purely speculative here.. but my guess is that when the page finishes processing the process is terminated. Try having the page wait for the process to close.
My 'work-around' for a similar requirement is this:
Use the ASP page to create a CMD or BAT file on the server.
Create/write a service that 'watches' for the CMD/BAT file - and when it finds one, it runs it. The service can be written to start a process as a user.