Skip to content

ttakahari/AspNetCoreCurrentRequestContext

Repository files navigation

AspNetCoreCurrentRequestContext

Enable to use HttpContext.Current on ASP.NET Core applications.

AppVeyor NuGet

Install

from NuGet - AspNetCoreCurrentRequestContext

PM > Install-Package AspNetCoreCurrentRequestContext

How to use

At first, you have to add CurrentRequestContextMiddleware to IApplicationBuilder on Configure method in Startup class.

You can use the extension-method that is UseCurrentRequestContext for doing that.

public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        // add CurrentRequestContextMiddleware.
        app.UseCurrentRequestContext();
    }
}

After that, if you call AspNetCoreHttpContext.Current like HttpContext.Current on ASP.NET applications, you can use HttpContext everywhere.

// you can get HttpContext in the current request.
var context = AspNetCoreHttpContext.Current;

Lisence

under MIT Lisence.

About

Enable HttpContext.Current on ASP.NET Core applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages