.NET Core and IIS - performance

We currently have a web api targeting .NET 4 framework which is hosted within IIS using an application pool which is using .NET 4 CLR.
We are investigating migrating the web api from .NET 4 to .NET Core 2.1 (for performance improvements). The web api has other DLL references which have been built using .NET 4 framework. I have a simple proof of concept up and running using .NET Core 2.1 and the references which had been built using .NET 4 framework appear to have imported fine as I can reference them and the project builds.
If I have the new .NET Core 2.1 web api referencing the 3rd party DLLs using .NET framework 4 which is then going to be hosted in IIS using the CLR 4... how would we see any performance increase? If everything is being run using the CLR 4, is that not the bottleneck for performance? Or is it the binaries that the CLR reads being more performant where you will see better performance?
Any guidance would be greatly appreciated as I'm very confused at the moment!
Thanks

It depends on how you're handling things. .NET Core 2.0+ fully supports .NET Standard 2.0, which has an API footprint large enough to cover most .NET Framework functionality. As a result, the compiler will let you add a .NET Framework library reference to a project that's actually targeting .NET Core 2.0+. There's no guarantee that the library will actually work (and you get a warning to that effect), but unless it's using Windows-specific APIs, there's a very good chance it will function fine.
Assuming this is the case with your .NET Framework libraries and you're actually targeting something like .NET Core 2.1, then you are not in fact using .NET Framework, and you don't even need .NET Framework installed on the server you're deploying to. All the requisite framework dependencies will come from the .NET Core runtime, or can even be packaged along with your app if you opt for a self-contained deployment. In that case, once compiled, it's virtually inconsequential that the libraries you referenced actually targeted .NET Framework.
If however the libraries do not work without full .NET Framework, you can still build a .NET Core app, but you'll be forced to continue to target .NET Framework, rather than .NET Core. In that case, you will of course be reliant on the .NET Framework CLR, with the performance drain that entails. That said, an ASP.NET Core app, for example, is still generally more performant than something like an ASP.NET MVC app, so you will get some gains - just not as much as if you were actually targeting .NET Core.
Regardless of what you ultimately end up targeting, your app is actually served via Kestrel. IIS acts merely as a reverse proxy.

Related

Compatibility Problems & Limitations when bridging/interfacing Old ASP.NET Webforms/.NET Framework 4 w/ newer .NET Core Web API, MVC & Razor Pages?

At work, we have an Old application developed with the following technologies:
Visual Studio 2010 Ultimate
.NET Framework 4
C# 4.0
ASP.NET WebForms
With our application we are Highly concerned with issues like:
-security,
-links,
-and users sessions.
We have some new software requirements features which in turn means that we have to add to the existing application.
We would like to use newer Microsoft .NET technologies for the new features.
However, we are concerned about compatibility problems. We have Visual Studio 2019, and we would like to develop the new features using Visual Studio 2019.
But, how far can we go before we have compatibility problems, and face other kinds of limitations?
Is it possible to successfully bridge the Old application with newer technologies like:
-.NET Core Web API
-.NET Core MVC
-.NET Core Razor Pages?
Again, we can Not compromise on the following:
-security
-links
-and users sessions
Yes, you can use both .net framework application and .net core application inside single hosted application. Same thing i have done in one of my project. old project was in .net framework 4.5 and we wanted to build new features in .net core with web api.
We did and integrate both application inside a single application which is hosted on IIS server.
In term of security and sessions , .net core provide more control over these things.
Let me know if you need more help of info.

How do I convert a project from targeting .net core to target framework to a .net standard?

I created a new .net core 3.1 project and built it using VS2019 16.4.4
Now I want to change it to .Net Standard.
I know to go to the project properties and select the Target framework combo.
However no Standard framework options appear.
If I select Install other frameworks then I am taken to The download .Net SDKs for Visual Studio page
However the SDK I want is already installed on my machine.
Why am I not seeing what I want in the combo box.?
.NET Standard, like .NET Core and .NET Framework, is separate framework, so you can't switch that easily. You would need to create separate project targeting .NET Standard. Once you do it, you will see other options in 'Target framework'.
Worth to mention, you can't reference .NET Core and .NET Framework projects from your .NET Standard library, since .NET Standard is just an abstraction which is built differently depending on the executing environment (.NET Core or Framework)

How to convert NetFramwork 4 code to NetCore 2?

I have a C# project which was created using NetFramework 4.6. I want to convert it to using the NetCore 2.1.
I checked the network, and people say I can just change the Target Framework value in the project's properties page. But on my computer, I cannot see options for NetCore.
I already have the NetCore 2.1 SDK installed.
Is there another way to convert the project? Is there something wrong with my project that prevents it getting converted?
People are wrong, there is no such "one step" approach.
Remember that .NET Core is not a higher version of .NET Framework, it is rather a rewrite from scratch. So it does not work like retargeting .NET Framework version form 4.0 to 4.5.
Porting to .NET Core from .NET Framework is a good place to get started.
Edit: This page lists some differences between .NET Core and .NET Framework.
You can't do this simply like this; because of their totally different frameworks, not different versions of same framework. You have to port your project to .net core; there is one of the nice extension for visual studio that generate a report for you about how portable your code is between .NET Framework and .NET Core.
This is also one of the article about the issue that may be useful for you.

Bundle .NET 3.5 libs with app, so it runs on machines with only .NET 2.0 installed?

I want to use LINQ on machines with only .NET Framework 2.0 installed.
I've alread read about LINQBridge. But can't I simply set "copy local" to the referenced assemblies like System.Core.dll and System.Xml.Linq.dll to get the functionality I need?
Are there any drawbacks? Is this even allowed?
.Net 3.5 is really just .Net 2.0 with some extra dlls. There is no 3.5 runtime. If you include the dlls you need, the application will run without any problems.
From the following article concerning the linq bridge comment: http://www.albahari.com/nutshell/linqbridge.aspx
First, it's important to understand
that C# 3.0 and Framework 3.5 are
designed to work with CLR 2.0—the same
CLR version that Framework 2.0 uses.
This means that the C# 3.0 compiler
emits IL code that runs on the same
virtual machine as before.
This makes Framework 3.5 additive—just
as Framework 3.0 was
additive—comprising additional
assemblies that enhance the existing
2.0 Framework and CLR. So there's nothing to stop us from writing our
own assemblies that do the work of
Framework 3.5 (at least, the critical
bits required for local LINQ queries).
The compiler then looks for Where,
OrderBy and Select methods. The
critical thing is that it can find
appropriately named methods with the
correct signatures (typically
extension methods). But it doesn't
matter what assembly the methods come
from. LINQBridge simply provides
another source of these methods—that
are functionally identically to those
implemented in the Framework 3.5
assemblies.

Target framework, what does ".NET Framework ... Client Profile" mean?

In Visual Studio 2008, the target framework settings for a project are
.NET Framework 2.0
.NET Framework 3.0
.NET Framework 3.5
However, in Visual Studio 2010 they are
.NET Framework 2.0
.NET Framework 3.0
.NET Framework 3.5
.NET Framework 3.5 Client Profile
.NET Framework 4
.NET Framework 4 Client Profile
What do the Client Profile settings mean?
Edit
A little more experimentation shows that with MVC, WebForms and WCF projects you don't get the Client Profile options. When creating WinForms and Console applications, the default target framework is .NET 4 Client Profile. Which makes sense.
The client profile is a smaller version of the full .NET framework that contains only the more commonly used content. Scott wrote a nice post about this. Here and here is an official introduction.
The client profile was added recently, so VS 2008 does not know about it yet. The client profile is one of the major features that come with .NET 4 and VS 2010. Since the Client Profile is a subset of the full .NET 4 framework, you don't need to install it if you already got the full .NET 4.
It can be an advantage to develop against the Client Profile since it exists on more machines than the full framework (and it is smaller in download size for your customers).
The disadvantage that comes along naturally - it does not include everything. If you are developing a server application or a program that uses uncommon parts of the framework, you'll need the full framework in any case. Typical client programs, however, are likely satisfied with the Client Profile.
The Client Profiles are smaller, more compact versions of the .Net Framework. More info here.
It is a subset of the .NET framework for CLIENT applications (i.e. applications installed on the client computer).
As such, they do not incorporate server technologies. THis allows the client download to only install a smaller part.
Server technologies are for example ASP.NET.
Using ".net client profile" as search on Google, first link leads to http://msdn.microsoft.com/en-us/library/cc656912.aspx which has a detailed explanation.
Also the local .NET documentation (F1 - I hope you are aware this exists) has the same content.

Resources