What is the alternate of HttpRequest.EnableRewind() in ASP.NET Core 3.0? - httprequest

BufferingHelper.EnableRewind();
Above is an extension method for HttpRequest object in ASP.NET Core 2.2. It is no more there in ASP.NET Core 3.0 (atleast with this name). I want to know it's alternate in ASP.NET Core 3.0. I am not sure if
HttpRequestRewindExtensions.EnableBuffering();
is the alternate.

The alternate is HttpRequestRewindExtensions.EnableBuffering(), indeed. You can see here that internally it just calls EnableRewind().

Related

How should I implement a supported health check for .NET Core 2.1?

For a .NET Core 2.0 project, I used Microsoft standard health check libraries which are clearly documented based on code for .NET Core 2.0. Since less than a month, suddenly, this is deprecated. The new readme file, refers to an alternative for .NET Core 2.2 .However, the version of .NET Core that is production ready, recommended and has long term support, is version 2.1 which is exactly what I use now for a new project.
So I am in trouble. What is the supported way of implementing health checks for .NET Core 2.1? This used to be clear for .NET Core 2.0 and shall be clear for .NET Core 2.2 but for .NET Core 2.1 it is unclear what I should do.
You answered your own question actually, with the reference links.
ASP.NET Core 2.2 comes with its own official heath check, see Docs and the ASP.NET Core 2.2.0-preview1 blog post for the new health service.
You can use either one (2.2 or your old solution) for the ASP.NET Core 2.x life-time. Since the old one is deprecated it won't be updated for newer versions of ASP.NET Core, but you should expect it to work for the 2.x lines.
By the time ASP.NET Core 3.0 is out and you want to migrate to it, you should switch to the health services introduced in ASP.NET Core 2.2.
General consensus about new features in minor versions (which replace or change previous behavior) is to support them for the current main version and drop the old functionality in the next major, i.e. the new [ApiController] attribute and automatic model validation was added in ASP.NET Core 2.1. By default, the 2.0 compatibility will be used and the new behavior won't be available unless you opt-in. Once 3.0 is released, the old features/behavior will be removed and only the new one will be used.

How to disable verification for specific controller in ASP.NET Core

There is controller with methods. Request validation must be disable for one of method. I try use attribute [ValidateInput(false)], but visual studio cannot find it. I use .net core 2.1.
There is no request validation in ASP.NET Core.

how implement Owin pipeline using Asp.net core

indeed you can't use third-party tools such as OData, Thinktecture Identity Server, ... in asp.net core application.
So, how we can use these features in asp.net core apps ?
is there any way to implement Owin pipeline beside asp core and have all these facilities too ?
easily you can use Owin pipeline beside Asp.net core, not as an alternative solution.
in this article there is a simple way to implement this architecture using Owin and asp.net core
Implement Owin pipeline using Asp.net Core

WebTelemetryInitializerBase in ASP.NET Core / MVC6

Is there an MVC6 compatible version of WebTelemetryInitializerBase that would work with ASP.NET Core (on the full .NET Framework)?
See my question here where I asked how to get HttpContext in my temeletry initializers. Unfortunately I didn't specify that I was using MVC 6 and thus no System.Web.HttpContext.
Yes, there is a version of this for aspnetcore. Check out the Microsoft Application Insights for ASP.NET Core applications repo.
There is an implementation of getting the WebUser found in /src/Microsoft.ApplicationInsights.AspNetCore/TelemetryInitializers/WebUserTelemetryInitializer.cs which you can use as a guide.
The TelemetryInitializerBase class is the one that consumes the IHttpContextAccessor which is used to get the HttpContext.
From there you can get the Microsoft.AspNetCore.Http.HttpContext.User which is they type of System.Security.Claims.ClaimsPrincipal

Migrating from OWIN to ASP.NET Core

When moving from OWIN to ASP.NET Core, I've found a bit of information about dependencies to migration, but I've not found information about these other topics:
The middle-ware pipeline. How is this different, or not?
The DelegatingHandler pipeline (e.g. Web API). How is this different, or not?
The startup.cs file. How is this different?
In short, it would be great to know what are the primary hot-spots that would need my attention, in order to move from OWIN to ASP.NET Core.
As a first example - ASP.NET Core does not appear to have HttpConfiguration. There are myriads of example plugins and services that assume its existence. I'd like to infer how to translate instructions for HttpConfiguration into whatever approach ASP.NET Core expects.
As another example, the Swashbuckle documentation gives instructions for setup with OWIN, but those instructions don't work with ASP.NET Core. If I understood the primary differences from OWIN, it would be easier to "guesstimate" how to install Swashbuckle into ASP.NET Core.
Note: Swashbuckle also gives instructions for self-hosted apps. That confuses me because I think of OWIN (vis-a-vis Katana) as being self-hosted already, and so it sounds redundant to me. But I don't think this is related to the present question.
My question has used Swashbuckle as an example, but I am not asking about Swashbuckle specifically.
Update
I've discovered that much of the information I'm looking for is in the article Transitioning from Web API 2 to ASP.NET MVC 6.
Middleware is quite similar between Katana and Core but you use HttpContext instead of IOwinContext.
Startup.cs is similar but there's much more DI support.
WebApi has been merged into MVC
DelegatingHandler is gone, use middleware instead.
HttpConfiguration has been split up into Routing and MvcOptions.
Also https://devblogs.microsoft.com/aspnet/katana-asp-net-5-and-bridging-the-gap/
I think you can start here. It's an entire chapter about OWIN with ASP.NET Core. Hope this helps.