Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Azure Service Fabric, what is the deference between a Stateless Web API and the ASP.NET Core Web API?

I haven't dug in that much, but what are the pros and cons of both.. Seems they are redundant, obviously the Core version is experimental and probably will not work with many core libraries like Odata and Entity Framework

like image 221
LastTribunal Avatar asked Feb 05 '23 06:02

LastTribunal


2 Answers

tl/dr: Stateless Web API is the older "classic" Web API. ASP.NET Core is the new stuff where all the new features are going.

More details:

Stateless Web API template:

  • "Classic" ASP.NET Web API 2 based on OWIN. Does not support MVC (no Razor server-side rendering).
  • Full .NET Framework only.
  • Uses the "classic" .NET project type (.csproj) in Visual Studio 2015.
  • Uses Katana for the web host, which is built on System.Net.HttpListener, which itself uses the Windows HTTP Server API (http.sys).

ASP.NET Core template:

  • New ASP.NET Core, which combines MVC and Web API and offers Razor server-side rendering and a wealth of new features from ASP.NET.
  • Full .NET Framework or .NET Core, but currently only full .NET Framework is supported in Service Fabric.
  • Uses the new .NET project type (.xproj) in Visual Studio 2015. Tooling for this project type in VS 2015 is considered "preview" and will remain so. Tooling is only considered "production" in the newer Visual Studio 2017 (where it has been changed back to .csproj). This is mainly why we currently have both project templates in VS 2015.
  • Uses either WebListener or Kestrel as the web host.
    • WebListener is also based on http.sys and is fully supported.
    • Kestrel is based on a completely different cross-platform library (libuv), and in its current state we don't recommend putting it in an Internet-facing production application without a reverse proxy to provide DoS protection.
like image 113
Vaclav Turecek Avatar answered Feb 08 '23 05:02

Vaclav Turecek


Then biggest difference is that the ASP.NET Core Web API is built on .NET Core really. Both types will give you a Stateless service, identical ServiceManifests, ETW loggers and they start up the service in an identical way.

The ASP.NET Core Web API template sets up a HTTP listener using an Microsoft.AspNetCore.Hosting.IWebHost inside a WebListenerCommunicationListener from the additional assembly Microsoft.ServiceFabric.AspNetCore.WebListener (which really only contains a helper to create the listener based of the ASP.NET Core host. It also gives you the scaffolding for an ASP.NET Core MVC based Web Api.

The Stateless Web API template sets up a HTTP listener using an Microsoft.Owin.Hosting.WebApp inside a OwinCommunicationListener which is included in your projects source instead.

There isn't any other difference in how Service Fabric handles the result of creating services from these two templates or what types of services you get, it's only a difference in what you get as a boiler plate to start working with. Also, there is nothing special about the projects that are setup by the templates, you can always create an empty project and add the NuGets and create the required PackageRoot files manually to create a new service.

You are basically choosing if you want to use .NET Core to build your service.

like image 20
yoape Avatar answered Feb 08 '23 05:02

yoape