Debugging .Net web api - c#

I built a .net web app using visual studio. I tested it in visual studio and it seemed to work fine. After publishing it locally and copying to my remote web server it seems to keep crashing the application pool and I'm not sure how to debug it.
How I published it: I published it locally and copied all the files to: wwwroot/ss/ on the remote server. After that, I installed the folder as an application in IIS. Because it was built using version .net 4.5 framework but I only had .net 4.0 application pools I did:
appcmd set apppool /apppool.name: api /managedRuntimeVersion:4.5
Now, anytime I go to the application using my url: mywebsite.com/ss/api/controller/param, I get a 503 service unavailable.
When I check the application pool after I go to that URL, the app pool has been shut down. I tried using try/catches, but it doesn't seem to help. All I see in the log file is:
2015-03-09 01:01:39 remoteIP 14132 siteIP 80 HTTP/1.1 GET /ss/api/controller/param 503 4 AppOffline api
What's the best way to debug this? Can I use a remote debugger? Is there any folder besides C:\Windows\System32\LogFiles\HTTPERR or logs/LogFiles folder in the site root where I can find more information about why it crashed?
EDIT:
If it is at all useful, I see in the event log:
I see several warnings:
A process serving application pool 'api' terminated unexpectedly. The process id was '2724'. The process exit code was '0xfffffffe'.
followed by:
Application pool 'api' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

There is no such thing as the .net 4.5 run time. Set it back to .net 4.0
appcmd set apppool /apppool.name: api /managedRuntimeVersion:4.0
Fun fact.
There are only 3 .net runtimes as of 2015-03-09
.net runtime 1.0
.net runtime 2.0
.net runtime 4.0
These runtimes allow you to run the following (ignoring the various SP)
.net runtime 1.0
.net framework 1.0
.net runtime 2.0
.net framework 2.0
.net framework 3.0
.net framework 3.5
.net runtime 4.0
.net framework 4.0
.net framework 4.5
.net framework 4.5.1
.net framework 4.5.2

Related

.NET 6 ASP.NET MVC project running on a IIS Server without .NET 6 installed. Why?

I have a big application made in ASP.NET MVC using .NET 5.
We wanted to test the feasibility and the possibility to bring it to .NET 6.
Usually, but not always these kind of operations are mostly painless because you just need to upgrade project framework to from .NET 5 to .NET6 (and vs2019 to vs2022)
Why I can run a web application built with .NET 6 in a server with .NET 5 installed?
Now, I did that upgrade, and to test it, I deployed our application to a test IIS server we have where the application is already up and running, with these installed, which are all part of Microsoft .NET 5.0.6 Hosting Bundle:
-Microsoft .NET 5.0.6 - Windows Server Hosting
-Microsoft .NET Runtime 5.0.6 both x86 and 64
-Visual C++ Redistributables
I then deployed the application with dotnet build command in release mode and deployed on it and to my surprise.... IT WORKED
I was quite sure I had to install .NET 6 hosting bundle or something, but I didn't.
Why?
I remember on the other .NET Framework projects, that if you made a project for a certain version of .NET Framework, but in your code you only used functionalities of the old ones, the project build would run without the need to install the new .NET Framework version.
Example:
I create a Console application which has targetframework "C# 9.0 released with .NET 5.0"
but in the code I don't use any of the new constructs and syntax in c# 9.0 but all the code uses C#8.0 constructs, I could run it on a machine with .NET Core 3.0 because it doesn't use any of the new constructs.
This is what is happening?
It means that I have an application with .NET 6 framework but in reality the server is not upgraded and is running with .NET 5 just because in the code I didn't use any of the C#10 new constructs and syntax?
Thanks

How to create and Deploy a Mono ASP.NET web project in Visual Studio?

So the web server i am using right now is a Apache web server which runs ASP.Net on mono but i can't seem to get a project up and running on the mono ASP.Net server as it all ways just lists the directories within the folder
I tried creating a ASP.Net project uploaded it didn't work
I tried creating a MVC project and uploading it, also did not work
I tried creating a project on a .net framework 4 and uploaded it but still no luck
I've run of out of ideas how to get this to work, is there i special way i should be compiling the project? or is there a specfic version of .net i should use, as the mono ASP.NET version says 4
Mono is a linux based runtime like the .NET framework is a windows based runtime. You don't have "mono ASP.NET web projects" - you have "ASP.NET web projects" that run on .net framework in windows or mono (maybe) in linux.
What I'd actually recommend you do is create a .net core site if this is a new project; microsoft provide core for windows and linux so it should be easier to get started developing something that compiles and runs on windows, and then is either transported compiled to linux or recompiled there.
Note that your apache (if you're dead set on using that) will probably need to be configured as a proxy so that it forwards requests through to Kestrel, which is hosting your app. Apache doesn't natively understand .NET anything, and will just see a .NET application as a bunch of folders and files

Can older ASP.net core applications (like asp.net core 2.0) run on a server with asp.net core 2.2 runtime installed on it?

I have some older asp.net core 2.0 programs that are running on a server with a asp.net 2.0 server bundler installed on it. I have recently starting working with asp.net 2.1 and 2.2 and I know that those won't run correctly if I don't have the updated server bundler from Microsoft installed. Will my older programs stop working if I install the new bundlers or will everything continue to work as it does now?
You can have multiple runtime of .Net core running side by side on your server. Here is some documention from Microsoft:
To install applications with dependencies on different versions of .NET, we recommend .NET Core. .NET Core offers side-by-side installation of different versions of the .NET Core runtime on the same machine. This side-by-side installation allows multiple services on the same server, each of them on its own version of .NET Core. It also lowers risks and saves money in application upgrades and IT operations.
https://learn.microsoft.com/en-us/dotnet/standard/choosing-core-framework-server

net 4.7 service install upgrade

I inherited a .net service project which does not support TLS 1.2, project was upgraded to .net 4.7. Previous .exe file was replaced with the new 4.7exe and the service was restarted. Service cannot be started due to error "1064:An exception occurred in the service when handling the control request"
Do I have to use installutil.exe MyNewService.exe to install a service?
The installutil.exe is located in C:\Windows\Microsoft.NET\Framework\v4.0.30319, would this support .net 4.7 or do I need to download and install .NET Framework 4.7 offline installer for Windows?
Thanks for any tips or suggestions, I am not familiar with .net services!
Ensure you include all output files from the build, including the app.config file. There might be assembly redirects there which are required by 4.7.
Is the correct .NET Framework version installed on the server you're running the service on?
If that doesn't help, try running the application from command prompt, if your application supports it (I recommend it should). If that works, the service user running the service might be missing some permissions.
Add logging. As minimum, add try-catch statements in your service entry points and log any exceptions to a file. You can also add a handler to AppDomain.UnhandledException which will -usually- be called before the application crashes.

ClickOnce Deployment .Net Framework 4.6.1 installation error

I have a clickonce application being tested on a virtual machine. This virtual machine is empty and my application requires .Net Framework 4.6.1 on the machine. Now, my application is able to install .Net 4.6.1 but I'm having a weird behavior after install. I'm receiving this message when the application is being open after the installation of .Net 4.6.1.
I added 4.6.1 on my prerequisite by following this guide. How to Create .Net Framework Prerequisites Entry in Microsoft Visual Studio 2015
Here's the message
When I try to run the setup again, the setup process goes through then it launches my application. It seems the setup cannot detect the framework installed right after it install it. Or something went wrong somewhere during the installation. Is there a way to handle this? Any suggestion will be appreciated. Thanks!
The error message says that your application requires CLR 4.0.xxxx. If you specify .NET 4.0 as requirement too ? Maybe you are trying to execute something developped with .NET 4.0 anyway. This could help you :
Backward compatibility and the .NET Framework 4.5 :
The .NET Framework 4.5 and its point releases are backward-compatible with apps that were built with earlier versions of the .NET Framework.In other words, apps and components built with previous versions will work without modification on the .NET Framework 4.5.However, by default, apps run on the version of the common language runtime for which they were developed, so you may have to provide a configuration file to enable your app to run on the .NET Framework 4.5.For more information, see the Version compatibility for apps section earlier in this article.
source

Categories

Resources