I'm migrating a bunch of .Net Framework projects to .Net Core 2.1, and the current project uses WCF. I've tried to use the wcf client for net core, but I'm left with two statements I don't know how to rewrite (element is a BindingElementCollection):
elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true;, EnableUnsecuredResponse is not a property of the dotnet version of SecurityBindingElement
elements.Find<MtomMessageEncodingBindingElement>().MaxBufferSize = 200000000;, MtomMessageEncodingBindingElement does not exist.
Related
I have a an MVC .NET Framework 4.7.2 that I am migrating to .NET 6. The .NET Framework had a NuGet package library that was built in house (company I work for) and expected HttpRequestBase as a parameter. How would I pass in a parameter from .NET 6 to this library?
So far I am thinking that this NuGet Package will have to be upgrade to expect a parameter of
Microsoft.AspNetCore.Http.HttpRequest ?
In ASP.NET Core, I suggest you use HttpContext.
For example, getting query string in ASP.NET Core MVC:
public class HomeController: Controller
{
public void Index(string name)
{
var data = HttpContext.Request.QueryString;
}
}
My solution comes from https://www.youtube.com/watch?v=P96l0pDNVpM or you can read the article https://devblogs.microsoft.com/dotnet/incremental-asp-net-to-asp-net-core-migration/
I did a test and converted my .NET Framework library to .NET Standard and added package Microsoft.AspNetCore.SystemWebAdapters.
I compiled and took the DLLs to the .NET Core Web project and was able to call the method that was expecting the paramater HttpRequestBase request
My .NET Core Web project did have package Microsoft.AspNetCore.SystemWebAdapters to work with converting the old project (.NET Framework MVC)
I have an ASP NET MVC project with net471 target framework but I found nuget reference to Microsoft.AspNetCore.* or Microsoft.EntityFrameworkCore.*
It's correct? What problems can it entail?
It depends. First, I'm not sure if you're using terminology correct. Do you have an ASP.NET MVC 5 project or an ASP.NET Core project? If the former, then yes, it's very much incorrect. If the latter, then no it's fine, depending on the ASP.NET Core version.
.NET Framework 4.7.1 implements .NET Standard 2.0, which .NET Core 2.2 is also compatible with. Therefore, you can include ASP.NET Core 2.2 packages in a .NET Framework 4.7.1 project. Despite the name, an ASP.NET Core web app doesn't have to actually run on .NET Core. However, ASP.NET Core 3.0 or EF Core 3.0 would not work because those depend on .NET Standard 2.1, which no version of .NET Framework implements (and probably never will).
Is there a way to run/use .NET Framework app/dll in .NET Core WebAPI? I am aware that .NET Core does not work with .NET Framework so I am asking about somekind of workaround.
I have tried .NET Framework Console App that I open from WebAPI but I am not sure if that is good idea. It does not work anytime, specialy when two users tries run it at the same time.
string path = hostingEnvironment.ContentRootPath + exePath;
string json = ConvertToBase64(object);
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = path;
p.StartInfo.Arguments = json;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
return output;
I do not want to use .NET Framework for my API. I do not want to use RabbitMQ and similar because it is require couple of components to install.
I need to use some methods from .NET Framework dlls in .NET Core WebAPI. I do not have access to .NET Framework dll code.
In truth, it's not incompatible. .NET Core supports .NET Standard 2.0, which has a broad enough API footprint that most things in .NET Framework are supported as well. The main exclusions are obvious ones: Windows-specific APIs that obviously won't work cross-platform, which means they won't work in .NET Core.
As such, the answer to your question is another question: what exactly are the .NET Framework libraries doing? You can add a reference to the libraries from a .NET Core project, but you will get a warning telling you that they may not work correctly. It's on you to then determine if they do or do not work, and if everything is fine, you can suppress the warning.
If there are issues, then you can opt to target .NET Framework instead of .NET Core. You can still use ASP.NET Core while targeting .NET Framework; you simply will be tied to Windows, instead of able to deploy cross-platform. That may not even be an issue for you, though. Additionally, it may only be a temporary situation. .NET Core 3.0 should get you over any remaining humps, once it's released, so it's possible you can retarget your project to that later.
What exactly is the difference between .NET Core and ASP.NET Core?
Are they mutually exclusive? I heard ASP.NET Core is built on .NET Core, but it can also be built on the full .NET framework.
So what exactly is ASP.NET Core?
Update 2020: Do note that ASP.NET Core 3 and higher now depend on .NET Core and can no longer be used on .NET Framework. The below description is for ASP.NET Core 1.x-2.x; the layer separation still holds true for ASP.NET Core 3.0 but the ASP.NET Core layer can no longer be used on top of .NET Framework in 3.0+.
.NET Core is a runtime. It can execute applications that are built for it.
ASP.NET Core is a collection of libraries that form a Framework for building web applications.
ASP.NET Core libraries can be used on both .NET Core and the "Full .NET Framework" (which has shipped with windows for many years).
The confusing part is that an application using the libraries and tools of ASP.NET Core is usually referred to as "ASP.NET Core Application", which in theory doesn't say if it is built for .NET Core or .NET Framework. So an "ASP.NET Core Application" is also a ".NET Core Application" or a ".NET Framework Application".
This image shows the relation of the involved technologies (taken from this blog post)
Here you can see that ASP.NET Core is built "on top of" both .NET Framework and .NET Core, while "ASP.NET" (now often referred to as "classic ASP.NET") is .NET Framework only.
ASP.NET Core using .NET Core - all dependencies are self-contained, can use most NuGet packages, can't use Windows-specific packages, can execute on Windows, Linux, and Mac.
ASP.NET Core using .NET Framework - most dependencies are self-contained, only executes on Windows, will have access to Windows-specific NuGet packages, needs the .NET framework version which is targeted installed on the machine.
ASP.NET Core is one of the workloads supported by .NET Core.
From .NET Core guide:
By itself, .NET Core includes a single application model -- console apps -- which is useful for tools, local services and text-based games. Additional application models have been built on top of .NET Core to extend its functionality, such as:
ASP.NET Core
Windows 10 Universal Windows Platform (UWP)
Xamarin.Forms
The .NET Framework is on its last release. There will not be another one after 4.8. Microsoft will continue with .NET Core. From this time you should prefer .NET Core on your projects.
Official update (source):
.NET 5 is the next major release of .NET Core following 3.1. We named this new release .NET 5 instead of .NET Core 4 for two reasons:
We skipped version numbers 4.x to avoid confusion with .NET Framework 4.x.
We dropped "Core" from the name to emphasize that this is the main implementation of .NET going forward. .NET 5 supports more types of apps and more platforms than .NET Core or .NET Framework.
ASP.NET Core 5.0 is based on .NET 5 but retains the name "Core" to avoid confusing it with ASP.NET MVC 5. Likewise, Entity Framework Core 5.0 retains the name "Core" to avoid confusing it with Entity Framework 5 and 6.
.NET Core is the next evolution of the .NET Framework, that allows Microsoft technology to be hosted on other OS platforms, rather than Windows.
ASP.NET is the web framework provided by Microsoft for building:
server-side rendered web pages/websites
server-side components for SPAs
MVC-fashion apps
web services/web APIs/microservices
ASP.NET runs only on Windows platforms.
Since .NET Core was created to provide the capability of running Microsoft tech on top of Linux/macOS, it implies that ASP.NET Core is the evolution of ASP.NET in the direction of multi-platform support.
In conclusion:
ASP.NET Core runs on both .NET Core and .NET 5.0, on top of multiple OS platforms: Windows, Linux & macOS.
ASP.NET 4.x (ASP.NET/ASP.NET MVC) runs on the .NET Framework only, on top of Windows OS.
Let's say I have:
ASP.NET Core stand alone Web API project for .NET Core framework
Class Library with EF6 data model for full .NET framework
The ASP.NET Core project refers to the class library
This architecture proposed here:
https://learn.microsoft.com/en-us/aspnet/core/data/entity-framework-6
The question is: will my standalone application be able to execute on the specified target platform (Win, Linux, Mac runtime) after Release (or Publish), if it's dependency targets to full .NET Framework?
Thanks very much
It will be not possible. The same link you provided confirm that:
To use Entity Framework 6, your project has to compile against .NET Framework, as Entity Framework 6 does not support .NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core.
You can use ASP.NET Core upon .NET Framework (Not .NET CORE) and EF6 (But not cross-platform). But not ASP.NET Core upon .NET Core and use EF6. You will need to use EF Core for that project.
Disclaimer: I'm the owner of the project Entity Framework Classic
That's not possible directly Entity Framework as #Adailson answered
However, it's possible via EF Classic: http://entityframework-classic.net/
That's an EF6 fork that also supports .NET Core. We plan to integrate a ton of features & bug fix.
A community (FREE) and enterprise version (PAID) is available.
What's EF Classic
Entity Framework Classic is a supported version from the latest EF6 code base. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.